Merging r259645:
[oota-llvm.git] / test / Analysis / DemandedBits / basic.ll
1 ; RUN: opt -S -demanded-bits -analyze < %s | FileCheck %s
2
3 ; CHECK-LABEL: 'test_mul'
4 ; CHECK-DAG: DemandedBits: 0xFF for   %1 = add nsw i32 %a, 5
5 ; CHECK-DAG: DemandedBits: 0xFF for   %3 = trunc i32 %2 to i8
6 ; CHECK-DAG: DemandedBits: 0xFF for   %2 = mul nsw i32 %1, %b
7 define i8 @test_mul(i32 %a, i32 %b) {
8   %1 = add nsw i32 %a, 5
9   %2 = mul nsw i32 %1, %b
10   %3 = trunc i32 %2 to i8
11   ret i8 %3
12 }
13
14 ; CHECK-LABEL: 'test_icmp1'
15 ; CHECK-DAG: DemandedBits: 0x1 for   %3 = icmp eq i32 %1, %2
16 ; CHECK-DAG: DemandedBits: 0xFFF for   %1 = and i32 %a, 255
17 ; CHECK-DAG: DemandedBits: 0xFFF for   %2 = shl i32 %1, 4
18 define i1 @test_icmp1(i32 %a, i32 %b) {
19   %1 = and i32 %a, 255
20   %2 = shl i32 %1, 4
21   %3 = icmp eq i32 %1, %2
22   ret i1 %3
23 }
24
25 ; CHECK-LABEL: 'test_icmp2'
26 ; CHECK-DAG: DemandedBits: 0x1 for   %3 = icmp eq i32 %1, %2
27 ; CHECK-DAG: DemandedBits: 0xFFF for   %1 = and i32 %a, 255
28 ; CHECK-DAG: DemandedBits: 0xFF for   %2 = ashr i32 %1, 4
29 define i1 @test_icmp2(i32 %a, i32 %b) {
30   %1 = and i32 %a, 255
31   %2 = ashr i32 %1, 4
32   %3 = icmp eq i32 %1, %2
33   ret i1 %3
34 }
35
36 ; CHECK-LABEL: 'test_icmp3'
37 ; CHECK-DAG: DemandedBits: 0xFFFFFFFF for   %1 = and i32 %a, 255
38 ; CHECK-DAG: DemandedBits: 0x1 for   %2 = icmp eq i32 -1, %1
39 define i1 @test_icmp3(i32 %a) {
40   %1 = and i32 %a, 255
41   %2 = icmp eq i32 -1, %1
42   ret i1 %2
43 }