• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; This test makes sure that xor instructions are properly eliminated.
2; This test is for Integer BitWidth <= 64 && BitWidth % 8 != 0.
3
4; RUN: opt < %s -instcombine -S | not grep "xor "
5
6
7define i47 @test1(i47 %A, i47 %B) {
8        ;; (A & C1)^(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
9        %A1 = and i47 %A, 70368744177664
10        %B1 = and i47 %B, 70368744177661
11        %C1 = xor i47 %A1, %B1
12        ret i47 %C1
13}
14
15define i15 @test2(i15 %x) {
16        %tmp.2 = xor i15 %x, 0
17        ret i15 %tmp.2
18}
19
20define i23 @test3(i23 %x) {
21        %tmp.2 = xor i23 %x, %x
22        ret i23 %tmp.2
23}
24
25define i37 @test4(i37 %x) {
26        ; x ^ ~x == -1
27        %NotX = xor i37 -1, %x
28        %B = xor i37 %x, %NotX
29        ret i37 %B
30}
31
32define i7 @test5(i7 %A) {
33        ;; (A|B)^B == A & (~B)
34        %t1 = or i7 %A, 23
35        %r = xor i7 %t1, 23
36        ret i7 %r
37}
38
39define i7 @test6(i7 %A) {
40        %t1 = xor i7 %A, 23
41        %r = xor i7 %t1, 23
42        ret i7 %r
43}
44
45define i47 @test7(i47 %A) {
46        ;; (A | C1) ^ C2 -> (A | C1) & ~C2 iff (C1&C2) == C2
47        %B1 = or i47 %A,   70368744177663
48        %C1 = xor i47 %B1, 703687463
49        ret i47 %C1
50}
51