Test source: git
Source: <stdin> ---------------------------------------- define i32 @select_clz_to_ctz(i32 %a) { %0: %sub = sub i32 0, %a %and = and i32 %sub, %a %lz = ctlz i32 %and, 1 %tobool = icmp eq i32 %a, 0 %sub1 = xor i32 %lz, 31 %cond = select i1 %tobool, i32 %lz, i32 %sub1 ret i32 %cond } => define i32 @select_clz_to_ctz(i32 %a) { %0: %cond = cttz i32 %a, 1 %range_l#0%cond = icmp sge i32 %cond, 0 %range_h#0%cond = icmp slt i32 %cond, 33 %range#0%cond = and i1 %range_l#0%cond, %range_h#0%cond assume_non_poison i1 %range#0%cond ret i32 %cond } Transformation seems to be correct! ---------------------------------------- define i32 @select_clz_to_ctz_preserve_flag(i32 %a) { %0: %sub = sub i32 0, %a %and = and i32 %sub, %a %lz = ctlz i32 %and, 0 %tobool = icmp eq i32 %a, 0 %sub1 = xor i32 %lz, 31 %cond = select i1 %tobool, i32 %lz, i32 %sub1 ret i32 %cond } => define i32 @select_clz_to_ctz_preserve_flag(i32 %a) { %0: %cond = cttz i32 %a, 0 %range_l#0%cond = icmp sge i32 %cond, 0 %range_h#0%cond = icmp slt i32 %cond, 33 %range#0%cond = and i1 %range_l#0%cond, %range_h#0%cond assume_non_poison i1 %range#0%cond ret i32 %cond } Transformation seems to be correct! ---------------------------------------- define <2 x i32> @select_clz_to_ctz_vec(<2 x i32> %a) { %0: %sub = sub <2 x i32> { 0, 0 }, %a %and = and <2 x i32> %sub, %a %lz = ctlz <2 x i32> %and, 1 %tobool = icmp eq <2 x i32> %a, { 0, 0 } %sub1 = xor <2 x i32> %lz, { 31, 31 } %cond = select <2 x i1> %tobool, <2 x i32> %lz, <2 x i32> %sub1 ret <2 x i32> %cond } => define <2 x i32> @select_clz_to_ctz_vec(<2 x i32> %a) { %0: %cond = cttz <2 x i32> %a, 1 ret <2 x i32> %cond } Transformation seems to be correct! ---------------------------------------- define i32 @select_clz_to_ctz_extra_use(i32 %a) { %0: %sub = sub i32 0, %a %and = and i32 %sub, %a %lz = ctlz i32 %and, 1 %tobool = icmp eq i32 %a, 0 %sub1 = xor i32 %lz, 31 call void @use(i32 %sub1) %cond = select i1 %tobool, i32 %lz, i32 %sub1 ret i32 %cond } => define i32 @select_clz_to_ctz_extra_use(i32 %a) { %0: %sub = sub i32 0, %a %and = and i32 %sub, %a %lz = ctlz i32 %and, 1 %range_l#0%lz = icmp sge i32 %lz, 0 %range_h#0%lz = icmp slt i32 %lz, 33 %range#0%lz = and i1 %range_l#0%lz, %range_h#0%lz assume_non_poison i1 %range#0%lz %sub1 = xor i32 %lz, 31 call void @use(i32 %sub1) %cond = cttz i32 %a, 1 %range_l#0%cond = icmp sge i32 %cond, 0 %range_h#0%cond = icmp slt i32 %cond, 33 %range#0%cond = and i1 %range_l#0%cond, %range_h#0%cond assume_non_poison i1 %range#0%cond ret i32 %cond } Transformation seems to be correct! ---------------------------------------- define i32 @select_clz_to_ctz_and_commuted(i32 %a) { %0: %sub = sub i32 0, %a %and = and i32 %a, %sub %lz = ctlz i32 %and, 1 %tobool = icmp eq i32 %a, 0 %sub1 = xor i32 %lz, 31 %cond = select i1 %tobool, i32 %lz, i32 %sub1 ret i32 %cond } => define i32 @select_clz_to_ctz_and_commuted(i32 %a) { %0: %cond = cttz i32 %a, 1 %range_l#0%cond = icmp sge i32 %cond, 0 %range_h#0%cond = icmp slt i32 %cond, 33 %range#0%cond = and i1 %range_l#0%cond, %range_h#0%cond assume_non_poison i1 %range#0%cond ret i32 %cond } Transformation seems to be correct! ---------------------------------------- define i32 @select_clz_to_ctz_icmp_ne(i32 %a) { %0: %sub = sub i32 0, %a %and = and i32 %sub, %a %lz = ctlz i32 %and, 1 %tobool = icmp ne i32 %a, 0 call void @use2(i1 %tobool) %sub1 = xor i32 %lz, 31 %cond = select i1 %tobool, i32 %sub1, i32 %lz ret i32 %cond } => define i32 @select_clz_to_ctz_icmp_ne(i32 %a) { %0: %tobool = icmp ne i32 %a, 0 call void @use2(i1 %tobool) %cond = cttz i32 %a, 1 %range_l#0%cond = icmp sge i32 %cond, 0 %range_h#0%cond = icmp slt i32 %cond, 33 %range#0%cond = and i1 %range_l#0%cond, %range_h#0%cond assume_non_poison i1 %range#0%cond ret i32 %cond } Transformation seems to be correct! ---------------------------------------- define i64 @select_clz_to_ctz_i64(i64 %a) { %0: %sub = sub i64 0, %a %and = and i64 %sub, %a %lz = ctlz i64 %and, 1 %tobool = icmp eq i64 %a, 0 %sub1 = xor i64 %lz, 63 %cond = select i1 %tobool, i64 %lz, i64 %sub1 ret i64 %cond } => define i64 @select_clz_to_ctz_i64(i64 %a) { %0: %cond = cttz i64 %a, 1 %range_l#0%cond = icmp sge i64 %cond, 0 %range_h#0%cond = icmp slt i64 %cond, 65 %range#0%cond = and i1 %range_l#0%cond, %range_h#0%cond assume_non_poison i1 %range#0%cond ret i64 %cond } Transformation seems to be correct! ---------------------------------------- define i32 @select_clz_to_ctz_wrong_sub(i32 %a) { %0: %sub = sub i32 1, %a %and = and i32 %sub, %a %lz = ctlz i32 %and, 1 %tobool = icmp eq i32 %a, 0 %sub1 = xor i32 %lz, 31 %cond = select i1 %tobool, i32 %lz, i32 %sub1 ret i32 %cond } => define i32 @select_clz_to_ctz_wrong_sub(i32 %a) { %0: %sub = sub i32 1, %a %and = and i32 %sub, %a %lz = ctlz i32 %and, 1 %range_l#0%lz = icmp sge i32 %lz, 0 %range_h#0%lz = icmp slt i32 %lz, 33 %range#0%lz = and i1 %range_l#0%lz, %range_h#0%lz assume_non_poison i1 %range#0%lz %tobool = icmp eq i32 %a, 0 %sub1 = xor i32 %lz, 31 %cond = select i1 %tobool, i32 %lz, i32 %sub1 ret i32 %cond } Transformation seems to be correct! ---------------------------------------- define i64 @select_clz_to_ctz_i64_wrong_xor(i64 %a) { %0: %sub = sub i64 0, %a %and = and i64 %sub, %a %lz = ctlz i64 %and, 1 %tobool = icmp eq i64 %a, 0 %sub1 = xor i64 %lz, 64 %cond = select i1 %tobool, i64 %lz, i64 %sub1 ret i64 %cond } => define i64 @select_clz_to_ctz_i64_wrong_xor(i64 %a) { %0: %sub = sub i64 0, %a %and = and i64 %sub, %a %lz = ctlz i64 %and, 1 %range_l#0%lz = icmp sge i64 %lz, 0 %range_h#0%lz = icmp slt i64 %lz, 65 %range#0%lz = and i1 %range_l#0%lz, %range_h#0%lz assume_non_poison i1 %range#0%lz %tobool = icmp eq i64 %a, 0 %sub11 = or i64 %lz, 64 %cond = select i1 %tobool, i64 %lz, i64 %sub11 ret i64 %cond } Transformation seems to be correct! ---------------------------------------- define i64 @select_clz_to_ctz_i64_wrong_icmp_cst(i64 %a) { %0: %sub = sub i64 0, %a %and = and i64 %sub, %a %lz = ctlz i64 %and, 1 %tobool = icmp eq i64 %a, 1 %sub1 = xor i64 %lz, 63 %cond = select i1 %tobool, i64 %lz, i64 %sub1 ret i64 %cond } => define i64 @select_clz_to_ctz_i64_wrong_icmp_cst(i64 %a) { %0: %sub = sub i64 0, %a %and = and i64 %sub, %a %lz = ctlz i64 %and, 1 %range_l#0%lz = icmp sge i64 %lz, 0 %range_h#0%lz = icmp slt i64 %lz, 65 %range#0%lz = and i1 %range_l#0%lz, %range_h#0%lz assume_non_poison i1 %range#0%lz %tobool = icmp eq i64 %a, 1 %sub1 = xor i64 %lz, 63 %cond = select i1 %tobool, i64 %lz, i64 %sub1 ret i64 %cond } Transformation seems to be correct! ---------------------------------------- define i64 @select_clz_to_ctz_i64_wrong_icmp_pred(i64 %a) { %0: %sub = sub i64 0, %a %and = and i64 %sub, %a %lz = ctlz i64 %and, 1 %tobool = icmp slt i64 %a, 0 %sub1 = xor i64 %lz, 63 %cond = select i1 %tobool, i64 %lz, i64 %sub1 ret i64 %cond } => define i64 @select_clz_to_ctz_i64_wrong_icmp_pred(i64 %a) { %0: %sub = sub i64 0, %a %and = and i64 %sub, %a %lz = ctlz i64 %and, 1 %range_l#0%lz = icmp sge i64 %lz, 0 %range_h#0%lz = icmp slt i64 %lz, 65 %range#0%lz = and i1 %range_l#0%lz, %range_h#0%lz assume_non_poison i1 %range#0%lz %tobool = icmp slt i64 %a, 0 %sub1 = xor i64 %lz, 63 %cond = select i1 %tobool, i64 %lz, i64 %sub1 ret i64 %cond } Transformation seems to be correct! ---------------------------------------- define <2 x i32> @select_clz_to_ctz_vec_with_undef(<2 x i32> %a) { %0: %sub = sub <2 x i32> { 0, 0 }, %a %and = and <2 x i32> %sub, %a %lz = ctlz <2 x i32> %and, 1 %tobool = icmp eq <2 x i32> %a, { 0, 0 } %sub1 = xor <2 x i32> %lz, { 31, undef } %cond = select <2 x i1> %tobool, <2 x i32> %lz, <2 x i32> %sub1 ret <2 x i32> %cond } => define <2 x i32> @select_clz_to_ctz_vec_with_undef(<2 x i32> %a) { %0: %sub = sub <2 x i32> { 0, 0 }, %a %and = and <2 x i32> %sub, %a %lz = ctlz <2 x i32> %and, 1 %tobool = icmp eq <2 x i32> %a, { 0, 0 } %sub1 = xor <2 x i32> %lz, { 31, undef } %cond = select <2 x i1> %tobool, <2 x i32> %lz, <2 x i32> %sub1 ret <2 x i32> %cond } Transformation seems to be correct! ---------------------------------------- define i4 @PR45762(i3 %x4) { %0: %t4 = cttz i3 %x4, 0 %t5 = icmp eq i3 %x4, 0 %t6 = select i1 %t5, i3 3, i3 %t4 %t7 = zext i3 %t6 to i4 %one_hot_16 = shl i4 1, %t7 %t8 = lshr i4 %one_hot_16, 0 %bit_slice_61 = trunc i4 %t8 to i1 %t9 = lshr i4 %one_hot_16, 1 %bit_slice_62 = trunc i4 %t9 to i1 %t10 = lshr i4 %one_hot_16, 2 %bit_slice_64 = trunc i4 %t10 to i1 %t11 = or i1 %bit_slice_61, %bit_slice_62 %or_69 = or i1 %t11, %bit_slice_64 %umul_23 = mul i4 %one_hot_16, %one_hot_16 %t12 = icmp eq i1 %or_69, 0 %sel_71 = select i1 %t12, i4 %one_hot_16, i4 %umul_23 ret i4 %sel_71 } => define i4 @PR45762(i3 %x4) { %0: %t4 = cttz i3 %x4, 0 %range_l#0%t4 = icmp sge i3 %t4, 0 %range_h#0%t4 = icmp slt i3 %t4, 4 %range#0%t4 = and i1 %range_l#0%t4, %range_h#0%t4 assume_non_poison i1 %range#0%t4 %t7 = zext i3 %t4 to i4 %one_hot_16 = shl i4 1, %t7 %1 = icmp eq i3 %x4, 0 %narrow = select i1 %1, i3 0, i3 %t4 %umul_23 = zext i3 %narrow to i4 %sel_71 = shl i4 %one_hot_16, %umul_23 ret i4 %sel_71 } Transformation doesn't verify! ERROR: Source is more defined than target Example: i3 %x4 = undef Source: i3 %t4 = #x3 (3) i1 %t5 = #x1 (1) i3 %t6 = #x3 (3) i4 %t7 = #x3 (3) i4 %one_hot_16 = #x8 (8, -8) i4 %t8 = #x8 (8, -8) i1 %bit_slice_61 = #x0 (0) i4 %t9 = #x4 (4) i1 %bit_slice_62 = #x0 (0) i4 %t10 = #x2 (2) i1 %bit_slice_64 = #x0 (0) i1 %t11 = #x0 (0) i1 %or_69 = #x0 (0) i4 %umul_23 = #x0 (0) i1 %t12 = #x1 (1) i4 %sel_71 = #x8 (8, -8) Target: i3 %t4 = #x3 (3) i1 %range_l#0%t4 = #x1 (1) i1 %range_h#0%t4 = #x0 (0) i1 %range#0%t4 = #x0 (0) i4 %t7 = #x3 (3) i4 %one_hot_16 = #x8 (8, -8) i1 %1 = #x1 (1) i3 %narrow = #x0 (0) i4 %umul_23 = #x0 (0) i4 %sel_71 = #x8 (8, -8) ------------------- SMT STATS ------------------- Num queries: 54 Num invalid: 0 Num skips: 0 Num trivial: 22 (28.9%) Num timeout: 0 (0.0%) Num errors: 0 (0.0%) Num SAT: 15 (27.8%) Num UNSAT: 39 (72.2%)
+ : 'RUN: at line 2' + /home/nlopes/alive2/scripts/opt-alive.sh -instcombine -S + /home/nlopes/llvm/build/bin/FileCheck /home/nlopes/llvm/llvm/test/Transforms/InstCombine/select-ctlz-to-cttz.ll Alive2: Transform doesn't verify; aborting! FileCheck error: '<stdin>' is empty. FileCheck command line: /home/nlopes/llvm/build/bin/FileCheck /home/nlopes/llvm/llvm/test/Transforms/InstCombine/select-ctlz-to-cttz.ll