recognize an unsigned add with overflow idiom into uadd.
[oota-llvm.git] / test / Transforms / InstCombine / 2010-11-01-lshr-mask.ll
1 ; RUN: opt -instcombine -S < %s | FileCheck %s
2
3 ; <rdar://problem/8606771>
4 ; CHECK: @main
5 define i32 @main(i32 %argc) nounwind ssp {
6 entry:
7   %tmp3151 = trunc i32 %argc to i8
8   %tmp3161 = or i8 %tmp3151, -17
9   %tmp3162 = and i8 %tmp3151, 122
10   %tmp3163 = xor i8 %tmp3162, -17
11   %tmp4114 = shl i8 %tmp3163, 6
12   %tmp4115 = xor i8 %tmp4114, %tmp3163
13   %tmp4120 = xor i8 %tmp3161, %tmp4115
14 ; CHECK: lshr i8 %tmp4115, 1
15 ; CHECK-NOT: shl i8 %tmp4126, 6
16   %tmp4126 = lshr i8 %tmp4120, 7
17   %tmp4127 = mul i8 %tmp4126, 64
18   %tmp4086 = zext i8 %tmp4127 to i32
19 ; CHECK: ret i32
20   ret i32 %tmp4086
21 }
22
23 ; rdar://8739316
24 ; CHECK: @foo
25 define i8 @foo(i8 %arg, i8 %arg1) nounwind {
26 bb:
27   %tmp = shl i8 %arg, 7
28   %tmp2 = and i8 %arg1, 84
29   %tmp3 = and i8 %arg1, -118
30   %tmp4 = and i8 %arg1, 33
31   %tmp5 = sub i8 -88, %tmp2
32   %tmp6 = and i8 %tmp5, 84
33   %tmp7 = or i8 %tmp4, %tmp6
34   %tmp8 = xor i8 %tmp, %tmp3
35   %tmp9 = or i8 %tmp7, %tmp8
36   %tmp10 = lshr i8 %tmp8, 7
37   %tmp11 = shl i8 %tmp10, 5
38
39 ; CHECK: %0 = lshr i8 %tmp8, 2
40 ; CHECK: %tmp11 = and i8 %0, 32
41
42   %tmp12 = xor i8 %tmp11, %tmp9
43   ret i8 %tmp12
44 }