1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -instcombine -instcombine-infinite-loop-threshold=2 -S < %s | FileCheck %s 3 4; <rdar://problem/8606771> 5define i32 @main(i32 %argc) { 6; CHECK-LABEL: @main( 7; CHECK-NEXT: [[T3151:%.*]] = trunc i32 [[ARGC:%.*]] to i8 8; CHECK-NEXT: [[T3163:%.*]] = xor i8 [[T3151]], -1 9; CHECK-NEXT: [[TMP1:%.*]] = shl i8 [[T3163]], 5 10; CHECK-NEXT: [[T4127:%.*]] = and i8 [[TMP1]], 64 11; CHECK-NEXT: [[T4086:%.*]] = zext i8 [[T4127]] to i32 12; CHECK-NEXT: ret i32 [[T4086]] 13; 14 %t3151 = trunc i32 %argc to i8 15 %t3161 = or i8 %t3151, -17 16 %t3162 = and i8 %t3151, 122 17 %t3163 = xor i8 %t3162, -17 18 %t4114 = shl i8 %t3163, 6 19 %t4115 = xor i8 %t4114, %t3163 20 %t4120 = xor i8 %t3161, %t4115 21 %t4126 = lshr i8 %t4120, 7 22 %t4127 = mul i8 %t4126, 64 23 %t4086 = zext i8 %t4127 to i32 24 ret i32 %t4086 25} 26 27; rdar://8739316 28define i8 @foo(i8 %arg, i8 %arg1) { 29; CHECK-LABEL: @foo( 30; CHECK-NEXT: [[T:%.*]] = shl i8 [[ARG:%.*]], 7 31; CHECK-NEXT: [[T2:%.*]] = and i8 [[ARG1:%.*]], 84 32; CHECK-NEXT: [[T3:%.*]] = and i8 [[ARG1]], -118 33; CHECK-NEXT: [[T4:%.*]] = and i8 [[ARG1]], 33 34; CHECK-NEXT: [[T5:%.*]] = sub nsw i8 40, [[T2]] 35; CHECK-NEXT: [[T6:%.*]] = and i8 [[T5]], 84 36; CHECK-NEXT: [[T7:%.*]] = or i8 [[T4]], [[T6]] 37; CHECK-NEXT: [[T8:%.*]] = xor i8 [[T]], [[T3]] 38; CHECK-NEXT: [[T9:%.*]] = or i8 [[T7]], [[T8]] 39; CHECK-NEXT: [[TMP1:%.*]] = lshr i8 [[T8]], 2 40; CHECK-NEXT: [[T11:%.*]] = and i8 [[TMP1]], 32 41; CHECK-NEXT: [[T12:%.*]] = xor i8 [[T11]], [[T9]] 42; CHECK-NEXT: ret i8 [[T12]] 43; 44 %t = shl i8 %arg, 7 45 %t2 = and i8 %arg1, 84 46 %t3 = and i8 %arg1, -118 47 %t4 = and i8 %arg1, 33 48 %t5 = sub i8 -88, %t2 49 %t6 = and i8 %t5, 84 50 %t7 = or i8 %t4, %t6 51 %t8 = xor i8 %t, %t3 52 %t9 = or i8 %t7, %t8 53 %t10 = lshr i8 %t8, 7 54 %t11 = shl i8 %t10, 5 55 %t12 = xor i8 %t11, %t9 56 ret i8 %t12 57} 58