1 ; RUN: opt < %s -instcombine -S | FileCheck %s 2 3 define i64 @test1(i64 %A, i32 %B) { 4 %tmp12 = zext i32 %B to i64 5 %tmp3 = shl i64 %tmp12, 32 6 %tmp5 = add i64 %tmp3, %A 7 %tmp6 = and i64 %tmp5, 123 8 ret i64 %tmp6 9 ; CHECK: @test1 10 ; CHECK-NEXT: and i64 %A, 123 11 ; CHECK-NEXT: ret i64 12 } 13 14 define i32 @test2(i32 %A) { 15 %B = and i32 %A, 7 16 %C = and i32 %A, 32 17 %F = add i32 %B, %C 18 ret i32 %F 19 ; CHECK: @test2 20 ; CHECK-NEXT: and i32 %A, 39 21 ; CHECK-NEXT: ret i32 22 } 23 24 define i32 @test3(i32 %A) { 25 %B = and i32 %A, 128 26 %C = lshr i32 %A, 30 27 %F = add i32 %B, %C 28 ret i32 %F 29 ; CHECK: @test3 30 ; CHECK-NEXT: and 31 ; CHECK-NEXT: lshr 32 ; CHECK-NEXT: or i32 %B, %C 33 ; CHECK-NEXT: ret i32 34 } 35 36 define i32 @test4(i32 %A) { 37 %B = add nuw i32 %A, %A 38 ret i32 %B 39 ; CHECK: @test4 40 ; CHECK-NEXT: %B = shl nuw i32 %A, 1 41 ; CHECK-NEXT: ret i32 %B 42 } 43 44