• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; This test makes sure that these instructions are properly eliminated.
2;
3
4; RUN: opt < %s -instcombine -S | FileCheck %s
5; CHECK-NOT: xor
6
7define i32 @test1(i32 %A) {
8        %B = xor i32 %A, -1
9        %C = xor i32 %B, -1
10        ret i32 %C
11}
12
13define i1 @test2(i32 %A, i32 %B) {
14        ; Can change into setge
15        %cond = icmp sle i32 %A, %B
16        %Ret = xor i1 %cond, true
17        ret i1 %Ret
18}
19
20; Test that De Morgan's law can be instcombined.
21define i32 @test3(i32 %A, i32 %B) {
22        %a = xor i32 %A, -1
23        %b = xor i32 %B, -1
24        %c = and i32 %a, %b
25        %d = xor i32 %c, -1
26        ret i32 %d
27}
28
29; Test that De Morgan's law can work with constants.
30define i32 @test4(i32 %A, i32 %B) {
31        %a = xor i32 %A, -1
32        %c = and i32 %a, 5
33        %d = xor i32 %c, -1
34        ret i32 %d
35}
36
37; Test the mirror of De Morgan's law.
38define i32 @test5(i32 %A, i32 %B) {
39        %a = xor i32 %A, -1
40        %b = xor i32 %B, -1
41        %c = or i32 %a, %b
42        %d = xor i32 %c, -1
43        ret i32 %d
44}
45
46; PR2298
47define zeroext i8 @test6(i32 %a, i32 %b) {
48entry:
49	%tmp1not = xor i32 %a, -1
50	%tmp2not = xor i32 %b, -1
51	%tmp3 = icmp slt i32 %tmp1not, %tmp2not
52	%retval67 = zext i1 %tmp3 to i8
53	ret i8 %retval67
54}
55
56define <2 x i1> @test7(<2 x i32> %A, <2 x i32> %B) {
57        %cond = icmp sle <2 x i32> %A, %B
58        %Ret = xor <2 x i1> %cond, <i1 true, i1 true>
59        ret <2 x i1> %Ret
60}
61
62