xref: /llvm-project/llvm/test/Analysis/DemandedBits/basic.ll (revision 99b3b8e5b9ee234ab783a1f6079e1901bb1c9240)
1; RUN: opt -S -disable-output -passes="print<demanded-bits>" < %s 2>&1 | FileCheck %s
2
3; CHECK-LABEL: Printing analysis 'Demanded Bits Analysis' for function '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; CHECK-DAG: DemandedBits: 0x1 for   %4 = trunc i32 %2 to i1
8; CHECK-DAG: DemandedBits: 0xff for   %5 = zext i1 %4 to i8
9; CHECK-DAG: DemandedBits: 0xff for   %6 = add nsw i8 %3, %5
10; CHECK-DAG: DemandedBits: 0xff for %a in   %1 = add nsw i32 %a, 5
11; CHECK-DAG: DemandedBits: 0xff for 5 in   %1 = add nsw i32 %a, 5
12; CHECK-DAG: DemandedBits: 0xff for %1 in   %2 = mul nsw i32 %1, %b
13; CHECK-DAG: DemandedBits: 0xff for %b in   %2 = mul nsw i32 %1, %b
14; CHECK-DAG: DemandedBits: 0xff for %2 in   %3 = trunc i32 %2 to i8
15; CHECK-DAG: DemandedBits: 0x1 for %2 in   %4 = trunc i32 %2 to i1
16; CHECK-DAG: DemandedBits: 0x1 for %4 in   %5 = zext i1 %4 to i8
17; CHECK-DAG: DemandedBits: 0xff for %3 in   %6 = add nsw i8 %3, %5
18; CHECK-DAG: DemandedBits: 0xff for %5 in   %6 = add nsw i8 %3, %5
19define i8 @test_mul(i32 %a, i32 %b) {
20  %1 = add nsw i32 %a, 5
21  %2 = mul nsw i32 %1, %b
22  %3 = trunc i32 %2 to i8
23  %4 = trunc i32 %2 to i1
24  %5 = zext i1 %4 to i8
25  %6 = add nsw i8 %3, %5
26  ret i8 %6
27}
28