1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=aggressive-instcombine -S < %s | FileCheck %s
10 ;; static const char table[32] =
12 ;; 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
13 ;; 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
15 ;; return table[((unsigned)((x & -x) * 0x077CB531U)) >> 27];
19 @x = global i32 0, align 4
20 @.str = private constant [3 x i8] c"%u\00", align 1
21 @test.table = internal constant [32 x i8] c"\00\01\1C\02\1D\0E\18\03\1E\16\14\0F\19\11\04\08\1F\1B\0D\17\15\13\10\07\1A\0C\12\06\0B\05\0A\09", align 1
26 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @x, align 4
27 ; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.cttz.i32(i32 [[TMP0]], i1 true)
28 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP0]], 0
29 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP2]], i32 0, i32 [[TMP1]]
30 ; CHECK-NEXT: [[TMP4:%.*]] = trunc i32 [[TMP3]] to i8
31 ; CHECK-NEXT: [[CONV:%.*]] = zext i8 [[TMP4]] to i32
32 ; CHECK-NEXT: ret i32 [[CONV]]
35 %0 = load i32, ptr @x, align 4
37 %and = and i32 %0, %sub
38 %mul = mul i32 %and, 125613361
39 %shr = lshr i32 %mul, 27
40 %idxprom = zext i32 %shr to i64
41 %arrayidx = getelementptr inbounds [32 x i8], ptr @test.table, i64 0, i64 %idxprom
42 %1 = load i8, ptr %arrayidx, align 1
43 %conv = zext i8 %1 to i32