Home | History | Annotate | Download | only in InstSimplify
      1 ; RUN: opt < %s -instsimplify -S | not grep or
      2 
      3 ; Test the case where integer BitWidth <= 64 && BitWidth % 2 != 0.
      4 define 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 
     21 ; Test the case where Integer BitWidth > 64 && BitWidth <= 1024. 
     22 define i399 @test2(i399 %V, i399 %M) {
     23     ;; If we have: ((V + N) & C1) | (V & C2)
     24     ;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
     25     ;; replace with V+N.
     26     %C1 = xor i399 274877906943, -1 ;; C2 = 274877906943
     27     %N = and i399 %M, 18446742974197923840
     28     %A = add i399 %V, %N
     29     %B = and i399 %A, %C1
     30     %D = and i399 %V, 274877906943
     31     %R = or i399 %B, %D
     32     ret i399 %R
     33 ; CHECK-LABEL @test2
     34 ; CHECK-NEXT: and {{.*}}, 18446742974197923840
     35 ; CHECK-NEXT: add
     36 ; CHECK-NEXT: ret
     37 }
     38