1; NOTE: Assertions have been autogenerated by update_test_checks.py 2; RUN: opt < %s -instcombine -S | FileCheck %s 3 4define i32 @func1(i32 %a, i32 %b) { 5; CHECK-LABEL: @func1( 6; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, 1 7; CHECK-NEXT: [[TMP3:%.*]] = or i32 [[TMP1]], %b 8; CHECK-NEXT: ret i32 [[TMP3]] 9; 10 %tmp = or i32 %b, %a 11 %tmp1 = and i32 %tmp, 1 12 %tmp2 = and i32 %b, -2 13 %tmp3 = or i32 %tmp1, %tmp2 14 ret i32 %tmp3 15} 16 17define i32 @func2(i32 %a, i32 %b) { 18; CHECK-LABEL: @func2( 19; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, 1 20; CHECK-NEXT: [[TMP3:%.*]] = or i32 [[TMP1]], %b 21; CHECK-NEXT: ret i32 [[TMP3]] 22; 23 %tmp = or i32 %a, %b 24 %tmp1 = and i32 1, %tmp 25 %tmp2 = and i32 -2, %b 26 %tmp3 = or i32 %tmp1, %tmp2 27 ret i32 %tmp3 28} 29 30define i32 @func3(i32 %a, i32 %b) { 31; CHECK-LABEL: @func3( 32; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, 1 33; CHECK-NEXT: [[TMP3:%.*]] = or i32 [[TMP1]], %b 34; CHECK-NEXT: ret i32 [[TMP3]] 35; 36 %tmp = or i32 %b, %a 37 %tmp1 = and i32 %tmp, 1 38 %tmp2 = and i32 %b, -2 39 %tmp3 = or i32 %tmp2, %tmp1 40 ret i32 %tmp3 41} 42 43define i32 @func4(i32 %a, i32 %b) { 44; CHECK-LABEL: @func4( 45; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, 1 46; CHECK-NEXT: [[TMP3:%.*]] = or i32 [[TMP1]], %b 47; CHECK-NEXT: ret i32 [[TMP3]] 48; 49 %tmp = or i32 %a, %b 50 %tmp1 = and i32 1, %tmp 51 %tmp2 = and i32 -2, %b 52 %tmp3 = or i32 %tmp2, %tmp1 53 ret i32 %tmp3 54} 55 56