[InstCombine] foldICmpWithLowBitMaskedVal(): handle ~(-1 << y) mask

Summary:
Two folds are happening here:
1. https://rise4fun.com/Alive/oaFX
2. And then `foldICmpWithHighBitMask()` (D52001): https://rise4fun.com/Alive/wsP4

This change doesn't just add the handling for eq/ne predicates,
it actually builds upon the previous `foldICmpWithLowBitMaskedVal()` work,
so **all** the 16 fold variants* are immediately supported.

I'm indeed only testing these two predicates.
I do not feel like re-proving all 16 folds*, because they were already proven
for the general case of constant with all-ones in low bits. So as long as
the mask produces all-ones in low bits, i'm pretty sure the fold is valid.

But required, i can re-prove, let me know.

* eq/ne are commutative - 4 folds; ult/ule/ugt/uge - are not commutative (the commuted variant is InstSimplified), 4 folds; slt/sle/sgt/sge are not commutative - 4 folds. 12 folds in total.

https://bugs.llvm.org/show_bug.cgi?id=38123
https://bugs.llvm.org/show_bug.cgi?id=38708

Reviewers: spatel, craig.topper, RKSimon

Reviewed By: spatel

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D52146

llvm-svn: 342546
This commit is contained in:
Roman Lebedev 2018-09-19 13:35:27 +00:00
parent 0b835be7bb
commit 183a465dc6
3 changed files with 81 additions and 114 deletions

View File

@ -2883,7 +2883,10 @@ Instruction *InstCombiner::foldICmpInstWithConstantNotInt(ICmpInst &I) {
/// In this case, we are looking for comparisons that look like
/// a check for a lossy truncation.
/// Folds:
/// x & (-1 >> y) SrcPred x to x DstPred (-1 >> y)
/// icmp SrcPred (x & Mask), x to icmp DstPred x, Mask
/// Where Mask is some pattern that produces all-ones in low bits:
/// (-1 >> y)
/// ~(-1 << y)
/// The Mask can be a constant, too.
/// For some predicates, the operands are commutative.
/// For others, x can only be on a specific side.
@ -2891,7 +2894,9 @@ static Value *foldICmpWithLowBitMaskedVal(ICmpInst &I,
InstCombiner::BuilderTy &Builder) {
ICmpInst::Predicate SrcPred;
Value *X, *M;
auto m_Mask = m_CombineOr(m_LShr(m_AllOnes(), m_Value()), m_LowBitMask());
auto m_VariableMask = m_CombineOr(m_Not(m_Shl(m_AllOnes(), m_Value())),
m_LShr(m_AllOnes(), m_Value()));
auto m_Mask = m_CombineOr(m_VariableMask, m_LowBitMask());
if (!match(&I, m_c_ICmp(SrcPred,
m_c_And(m_CombineAnd(m_Mask, m_Value(M)), m_Value(X)),
m_Deferred(X))))

View File

@ -16,11 +16,9 @@
define i1 @p0(i8 %x, i8 %y) {
; CHECK-LABEL: @p0(
; CHECK-NEXT: [[T0:%.*]] = shl i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: [[T2:%.*]] = and i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp eq i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr i8 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[X_HIGHBITS]], 0
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
%t1 = xor i8 %t0, -1
@ -35,11 +33,9 @@ define i1 @p0(i8 %x, i8 %y) {
define <2 x i1> @p1_vec(<2 x i8> %x, <2 x i8> %y) {
; CHECK-LABEL: @p1_vec(
; CHECK-NEXT: [[T0:%.*]] = shl <2 x i8> <i8 -1, i8 -1>, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor <2 x i8> [[T0]], <i8 -1, i8 -1>
; CHECK-NEXT: [[T2:%.*]] = and <2 x i8> [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp eq <2 x i8> [[T2]], [[X]]
; CHECK-NEXT: ret <2 x i1> [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr <2 x i8> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i8> [[X_HIGHBITS]], zeroinitializer
; CHECK-NEXT: ret <2 x i1> [[TMP1]]
;
%t0 = shl <2 x i8> <i8 -1, i8 -1>, %y
%t1 = xor <2 x i8> %t0, <i8 -1, i8 -1>
@ -50,11 +46,9 @@ define <2 x i1> @p1_vec(<2 x i8> %x, <2 x i8> %y) {
define <3 x i1> @p2_vec_undef0(<3 x i8> %x, <3 x i8> %y) {
; CHECK-LABEL: @p2_vec_undef0(
; CHECK-NEXT: [[T0:%.*]] = shl <3 x i8> <i8 -1, i8 undef, i8 -1>, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor <3 x i8> [[T0]], <i8 -1, i8 -1, i8 -1>
; CHECK-NEXT: [[T2:%.*]] = and <3 x i8> [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp eq <3 x i8> [[T2]], [[X]]
; CHECK-NEXT: ret <3 x i1> [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr <3 x i8> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <3 x i8> [[X_HIGHBITS]], zeroinitializer
; CHECK-NEXT: ret <3 x i1> [[TMP1]]
;
%t0 = shl <3 x i8> <i8 -1, i8 undef, i8 -1>, %y
%t1 = xor <3 x i8> %t0, <i8 -1, i8 -1, i8 -1>
@ -65,11 +59,9 @@ define <3 x i1> @p2_vec_undef0(<3 x i8> %x, <3 x i8> %y) {
define <3 x i1> @p3_vec_undef0(<3 x i8> %x, <3 x i8> %y) {
; CHECK-LABEL: @p3_vec_undef0(
; CHECK-NEXT: [[T0:%.*]] = shl <3 x i8> <i8 -1, i8 -1, i8 -1>, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor <3 x i8> [[T0]], <i8 -1, i8 undef, i8 -1>
; CHECK-NEXT: [[T2:%.*]] = and <3 x i8> [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp eq <3 x i8> [[T2]], [[X]]
; CHECK-NEXT: ret <3 x i1> [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr <3 x i8> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <3 x i8> [[X_HIGHBITS]], zeroinitializer
; CHECK-NEXT: ret <3 x i1> [[TMP1]]
;
%t0 = shl <3 x i8> <i8 -1, i8 -1, i8 -1>, %y
%t1 = xor <3 x i8> %t0, <i8 -1, i8 undef, i8 -1>
@ -80,11 +72,9 @@ define <3 x i1> @p3_vec_undef0(<3 x i8> %x, <3 x i8> %y) {
define <3 x i1> @p4_vec_undef2(<3 x i8> %x, <3 x i8> %y) {
; CHECK-LABEL: @p4_vec_undef2(
; CHECK-NEXT: [[T0:%.*]] = shl <3 x i8> <i8 -1, i8 undef, i8 -1>, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor <3 x i8> [[T0]], <i8 -1, i8 undef, i8 -1>
; CHECK-NEXT: [[T2:%.*]] = and <3 x i8> [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp eq <3 x i8> [[T2]], [[X]]
; CHECK-NEXT: ret <3 x i1> [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr <3 x i8> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <3 x i8> [[X_HIGHBITS]], zeroinitializer
; CHECK-NEXT: ret <3 x i1> [[TMP1]]
;
%t0 = shl <3 x i8> <i8 -1, i8 undef, i8 -1>, %y
%t1 = xor <3 x i8> %t0, <i8 -1, i8 undef, i8 -1>
@ -101,12 +91,10 @@ declare i8 @gen8()
define i1 @c0(i8 %y) {
; CHECK-LABEL: @c0(
; CHECK-NEXT: [[T0:%.*]] = shl i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
; CHECK-NEXT: [[T2:%.*]] = and i8 [[X]], [[T1]]
; CHECK-NEXT: [[RET:%.*]] = icmp eq i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr i8 [[X]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[X_HIGHBITS]], 0
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
%t1 = xor i8 %t0, -1
@ -118,12 +106,10 @@ define i1 @c0(i8 %y) {
define i1 @c1(i8 %y) {
; CHECK-LABEL: @c1(
; CHECK-NEXT: [[T0:%.*]] = shl i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
; CHECK-NEXT: [[T2:%.*]] = and i8 [[X]], [[T1]]
; CHECK-NEXT: [[RET:%.*]] = icmp eq i8 [[X]], [[T2]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr i8 [[X]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[X_HIGHBITS]], 0
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
%t1 = xor i8 %t0, -1
@ -135,12 +121,10 @@ define i1 @c1(i8 %y) {
define i1 @c2(i8 %y) {
; CHECK-LABEL: @c2(
; CHECK-NEXT: [[T0:%.*]] = shl i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
; CHECK-NEXT: [[T2:%.*]] = and i8 [[X]], [[T1]]
; CHECK-NEXT: [[RET:%.*]] = icmp eq i8 [[X]], [[T2]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr i8 [[X]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[X_HIGHBITS]], 0
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
%t1 = xor i8 %t0, -1
@ -160,10 +144,9 @@ define i1 @oneuse0(i8 %x, i8 %y) {
; CHECK-LABEL: @oneuse0(
; CHECK-NEXT: [[T0:%.*]] = shl i8 -1, [[Y:%.*]]
; CHECK-NEXT: call void @use8(i8 [[T0]])
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: [[T2:%.*]] = and i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp eq i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr i8 [[X:%.*]], [[Y]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[X_HIGHBITS]], 0
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
call void @use8(i8 %t0)
@ -178,9 +161,8 @@ define i1 @oneuse1(i8 %x, i8 %y) {
; CHECK-NEXT: [[T0:%.*]] = shl i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: call void @use8(i8 [[T1]])
; CHECK-NEXT: [[T2:%.*]] = and i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp eq i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp uge i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
%t1 = xor i8 %t0, -1
@ -196,8 +178,8 @@ define i1 @oneuse2(i8 %x, i8 %y) {
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: [[T2:%.*]] = and i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: call void @use8(i8 [[T2]])
; CHECK-NEXT: [[RET:%.*]] = icmp eq i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp uge i8 [[T1]], [[X]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
%t1 = xor i8 %t0, -1
@ -213,9 +195,8 @@ define i1 @oneuse3(i8 %x, i8 %y) {
; CHECK-NEXT: call void @use8(i8 [[T0]])
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: call void @use8(i8 [[T1]])
; CHECK-NEXT: [[T2:%.*]] = and i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp eq i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp uge i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
call void @use8(i8 %t0)
@ -233,8 +214,8 @@ define i1 @oneuse4(i8 %x, i8 %y) {
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: [[T2:%.*]] = and i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: call void @use8(i8 [[T2]])
; CHECK-NEXT: [[RET:%.*]] = icmp eq i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp uge i8 [[T1]], [[X]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
call void @use8(i8 %t0)
@ -253,8 +234,8 @@ define i1 @oneuse5(i8 %x, i8 %y) {
; CHECK-NEXT: call void @use8(i8 [[T1]])
; CHECK-NEXT: [[T2:%.*]] = and i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: call void @use8(i8 [[T2]])
; CHECK-NEXT: [[RET:%.*]] = icmp eq i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp uge i8 [[T1]], [[X]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
call void @use8(i8 %t0)

View File

@ -16,11 +16,9 @@
define i1 @p0(i8 %x, i8 %y) {
; CHECK-LABEL: @p0(
; CHECK-NEXT: [[T0:%.*]] = shl i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: [[T2:%.*]] = and i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp ne i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr i8 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i8 [[X_HIGHBITS]], 0
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
%t1 = xor i8 %t0, -1
@ -35,11 +33,9 @@ define i1 @p0(i8 %x, i8 %y) {
define <2 x i1> @p1_vec(<2 x i8> %x, <2 x i8> %y) {
; CHECK-LABEL: @p1_vec(
; CHECK-NEXT: [[T0:%.*]] = shl <2 x i8> <i8 -1, i8 -1>, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor <2 x i8> [[T0]], <i8 -1, i8 -1>
; CHECK-NEXT: [[T2:%.*]] = and <2 x i8> [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp ne <2 x i8> [[T2]], [[X]]
; CHECK-NEXT: ret <2 x i1> [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr <2 x i8> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne <2 x i8> [[X_HIGHBITS]], zeroinitializer
; CHECK-NEXT: ret <2 x i1> [[TMP1]]
;
%t0 = shl <2 x i8> <i8 -1, i8 -1>, %y
%t1 = xor <2 x i8> %t0, <i8 -1, i8 -1>
@ -50,11 +46,9 @@ define <2 x i1> @p1_vec(<2 x i8> %x, <2 x i8> %y) {
define <3 x i1> @p2_vec_undef0(<3 x i8> %x, <3 x i8> %y) {
; CHECK-LABEL: @p2_vec_undef0(
; CHECK-NEXT: [[T0:%.*]] = shl <3 x i8> <i8 -1, i8 undef, i8 -1>, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor <3 x i8> [[T0]], <i8 -1, i8 -1, i8 -1>
; CHECK-NEXT: [[T2:%.*]] = and <3 x i8> [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp ne <3 x i8> [[T2]], [[X]]
; CHECK-NEXT: ret <3 x i1> [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr <3 x i8> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne <3 x i8> [[X_HIGHBITS]], zeroinitializer
; CHECK-NEXT: ret <3 x i1> [[TMP1]]
;
%t0 = shl <3 x i8> <i8 -1, i8 undef, i8 -1>, %y
%t1 = xor <3 x i8> %t0, <i8 -1, i8 -1, i8 -1>
@ -65,11 +59,9 @@ define <3 x i1> @p2_vec_undef0(<3 x i8> %x, <3 x i8> %y) {
define <3 x i1> @p3_vec_undef0(<3 x i8> %x, <3 x i8> %y) {
; CHECK-LABEL: @p3_vec_undef0(
; CHECK-NEXT: [[T0:%.*]] = shl <3 x i8> <i8 -1, i8 -1, i8 -1>, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor <3 x i8> [[T0]], <i8 -1, i8 undef, i8 -1>
; CHECK-NEXT: [[T2:%.*]] = and <3 x i8> [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp ne <3 x i8> [[T2]], [[X]]
; CHECK-NEXT: ret <3 x i1> [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr <3 x i8> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne <3 x i8> [[X_HIGHBITS]], zeroinitializer
; CHECK-NEXT: ret <3 x i1> [[TMP1]]
;
%t0 = shl <3 x i8> <i8 -1, i8 -1, i8 -1>, %y
%t1 = xor <3 x i8> %t0, <i8 -1, i8 undef, i8 -1>
@ -80,11 +72,9 @@ define <3 x i1> @p3_vec_undef0(<3 x i8> %x, <3 x i8> %y) {
define <3 x i1> @p4_vec_undef2(<3 x i8> %x, <3 x i8> %y) {
; CHECK-LABEL: @p4_vec_undef2(
; CHECK-NEXT: [[T0:%.*]] = shl <3 x i8> <i8 -1, i8 undef, i8 -1>, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor <3 x i8> [[T0]], <i8 -1, i8 undef, i8 -1>
; CHECK-NEXT: [[T2:%.*]] = and <3 x i8> [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp ne <3 x i8> [[T2]], [[X]]
; CHECK-NEXT: ret <3 x i1> [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr <3 x i8> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne <3 x i8> [[X_HIGHBITS]], zeroinitializer
; CHECK-NEXT: ret <3 x i1> [[TMP1]]
;
%t0 = shl <3 x i8> <i8 -1, i8 undef, i8 -1>, %y
%t1 = xor <3 x i8> %t0, <i8 -1, i8 undef, i8 -1>
@ -101,12 +91,10 @@ declare i8 @gen8()
define i1 @c0(i8 %y) {
; CHECK-LABEL: @c0(
; CHECK-NEXT: [[T0:%.*]] = shl i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
; CHECK-NEXT: [[T2:%.*]] = and i8 [[X]], [[T1]]
; CHECK-NEXT: [[RET:%.*]] = icmp ne i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr i8 [[X]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i8 [[X_HIGHBITS]], 0
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
%t1 = xor i8 %t0, -1
@ -118,12 +106,10 @@ define i1 @c0(i8 %y) {
define i1 @c1(i8 %y) {
; CHECK-LABEL: @c1(
; CHECK-NEXT: [[T0:%.*]] = shl i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
; CHECK-NEXT: [[T2:%.*]] = and i8 [[X]], [[T1]]
; CHECK-NEXT: [[RET:%.*]] = icmp ne i8 [[X]], [[T2]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr i8 [[X]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i8 [[X_HIGHBITS]], 0
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
%t1 = xor i8 %t0, -1
@ -135,12 +121,10 @@ define i1 @c1(i8 %y) {
define i1 @c2(i8 %y) {
; CHECK-LABEL: @c2(
; CHECK-NEXT: [[T0:%.*]] = shl i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
; CHECK-NEXT: [[T2:%.*]] = and i8 [[X]], [[T1]]
; CHECK-NEXT: [[RET:%.*]] = icmp ne i8 [[X]], [[T2]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr i8 [[X]], [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i8 [[X_HIGHBITS]], 0
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
%t1 = xor i8 %t0, -1
@ -160,10 +144,9 @@ define i1 @oneuse0(i8 %x, i8 %y) {
; CHECK-LABEL: @oneuse0(
; CHECK-NEXT: [[T0:%.*]] = shl i8 -1, [[Y:%.*]]
; CHECK-NEXT: call void @use8(i8 [[T0]])
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: [[T2:%.*]] = and i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp ne i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[X_HIGHBITS:%.*]] = lshr i8 [[X:%.*]], [[Y]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i8 [[X_HIGHBITS]], 0
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
call void @use8(i8 %t0)
@ -178,9 +161,8 @@ define i1 @oneuse1(i8 %x, i8 %y) {
; CHECK-NEXT: [[T0:%.*]] = shl i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: call void @use8(i8 [[T1]])
; CHECK-NEXT: [[T2:%.*]] = and i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp ne i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
%t1 = xor i8 %t0, -1
@ -196,8 +178,8 @@ define i1 @oneuse2(i8 %x, i8 %y) {
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: [[T2:%.*]] = and i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: call void @use8(i8 [[T2]])
; CHECK-NEXT: [[RET:%.*]] = icmp ne i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i8 [[T1]], [[X]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
%t1 = xor i8 %t0, -1
@ -213,9 +195,8 @@ define i1 @oneuse3(i8 %x, i8 %y) {
; CHECK-NEXT: call void @use8(i8 [[T0]])
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: call void @use8(i8 [[T1]])
; CHECK-NEXT: [[T2:%.*]] = and i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: [[RET:%.*]] = icmp ne i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
call void @use8(i8 %t0)
@ -233,8 +214,8 @@ define i1 @oneuse4(i8 %x, i8 %y) {
; CHECK-NEXT: [[T1:%.*]] = xor i8 [[T0]], -1
; CHECK-NEXT: [[T2:%.*]] = and i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: call void @use8(i8 [[T2]])
; CHECK-NEXT: [[RET:%.*]] = icmp ne i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i8 [[T1]], [[X]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
call void @use8(i8 %t0)
@ -253,8 +234,8 @@ define i1 @oneuse5(i8 %x, i8 %y) {
; CHECK-NEXT: call void @use8(i8 [[T1]])
; CHECK-NEXT: [[T2:%.*]] = and i8 [[T1]], [[X:%.*]]
; CHECK-NEXT: call void @use8(i8 [[T2]])
; CHECK-NEXT: [[RET:%.*]] = icmp ne i8 [[T2]], [[X]]
; CHECK-NEXT: ret i1 [[RET]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i8 [[T1]], [[X]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%t0 = shl i8 -1, %y
call void @use8(i8 %t0)