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