• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -instsimplify -S | FileCheck %s
2
3; Test the case where integer BitWidth <= 64 && BitWidth % 2 != 0.
4define i39 @test1(i39 %V, i39 %M) {
5    ;; If we have: ((V + N) & C1) | (V & C2)
6    ;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
7    ;; replace with V+N.
8    %C1 = xor i39 274877906943, -1 ;; C2 = 274877906943
9    %N = and i39 %M, 274877906944
10    %A = add i39 %V, %N
11    %B = and i39 %A, %C1
12    %D = and i39 %V, 274877906943
13    %R = or i39 %B, %D
14    ret i39 %R
15; CHECK-LABEL: @test1
16; CHECK-NEXT: and {{.*}}, -274877906944
17; CHECK-NEXT: add
18; CHECK-NEXT: ret
19}
20
21define i7 @test2(i7 %X) {
22    %Y = or i7 %X, 0
23    ret i7 %Y
24; CHECK-LABEL: @test2
25; CHECK-NEXT: ret i7 %X
26}
27
28define i17 @test3(i17 %X) {
29    %Y = or i17 %X, -1
30    ret i17 %Y
31; CHECK-LABEL: @test3
32; CHECK-NEXT: ret i17 -1
33}
34
35; Test the case where Integer BitWidth > 64 && BitWidth <= 1024.
36define i399 @test4(i399 %V, i399 %M) {
37    ;; If we have: ((V + N) & C1) | (V & C2)
38    ;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
39    ;; replace with V+N.
40    %C1 = xor i399 274877906943, -1 ;; C2 = 274877906943
41    %N = and i399 %M, 18446742974197923840
42    %A = add i399 %V, %N
43    %B = and i399 %A, %C1
44    %D = and i399 %V, 274877906943
45    %R = or i399 %B, %D
46    ret i399 %R
47; CHECK-LABEL: @test4
48; CHECK-NEXT: and {{.*}}, 18446742974197923840
49; CHECK-NEXT: add
50; CHECK-NEXT: ret
51}
52
53define i777 @test5(i777 %X) {
54    %Y = or i777 %X, 0
55    ret i777 %Y
56; CHECK-LABEL: @test5
57; CHECK-NEXT: ret i777 %X
58}
59
60define i117 @test6(i117 %X) {
61    %Y = or i117 %X, -1
62    ret i117 %Y
63; CHECK-LABEL: @test6
64; CHECK-NEXT: ret i117 -1
65}
66