Index: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp =================================================================== --- llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -4500,6 +4500,25 @@ : new ICmpInst(ICmpInst::ICMP_UGT, CtPop, ConstantInt::get(Ty, 1)); } + // Match icmp eq (trunc (lsr A, BW), (ashr (trunc A), BW-1)), which checks the + // top BW/2 + 1 bits are all the same. Create "A >s INT_MIN && A getType()->getScalarSizeInBits(); + CmpInst::Predicate TPred; + if (match(&I, + m_c_ICmp( + TPred, m_Trunc(m_LShr(m_Value(A), m_SpecificInt(BitWidth))), + m_AShr(m_Trunc(m_Deferred(A)), m_SpecificInt(BitWidth - 1)))) && + A->getType()->getScalarSizeInBits() == BitWidth * 2 && + TPred == ICmpInst::ICMP_EQ && + (I.getOperand(0)->hasOneUse() || I.getOperand(1)->hasOneUse())) { + APInt C = APInt::getOneBitSet(BitWidth * 2, BitWidth - 1); + auto *Add = Builder.CreateAdd(A, ConstantInt::get(A->getType(), C)); + return new ICmpInst(ICmpInst::ICMP_ULT, Add, + ConstantInt::get(A->getType(), C.shl(1))); + } + return nullptr; } Index: llvm/test/Transforms/InstCombine/icmp-topbitssame.ll =================================================================== --- llvm/test/Transforms/InstCombine/icmp-topbitssame.ll +++ llvm/test/Transforms/InstCombine/icmp-topbitssame.ll @@ -7,11 +7,8 @@ define i1 @testi16i8(i16 %add) { ; CHECK-LABEL: @testi16i8( -; CHECK-NEXT: [[SH:%.*]] = lshr i16 [[ADD:%.*]], 8 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i16 [[SH]] to i8 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD]] to i8 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i8 [[CONV1_I]], 7 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i8 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[TMP1:%.*]] = add i16 [[ADD:%.*]], 128 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i16 [[TMP1]], 256 ; CHECK-NEXT: ret i1 [[CMP_NOT_I]] ; %sh = lshr i16 %add, 8 @@ -24,11 +21,8 @@ define i1 @testi16i8_com(i16 %add) { ; CHECK-LABEL: @testi16i8_com( -; CHECK-NEXT: [[SH:%.*]] = lshr i16 [[ADD:%.*]], 8 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i16 [[SH]] to i8 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD]] to i8 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i8 [[CONV1_I]], 7 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i8 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[TMP1:%.*]] = add i16 [[ADD:%.*]], 128 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i16 [[TMP1]], 256 ; CHECK-NEXT: ret i1 [[CMP_NOT_I]] ; %sh = lshr i16 %add, 8 @@ -41,11 +35,8 @@ define i1 @testi64i32(i64 %add) { ; CHECK-LABEL: @testi64i32( -; CHECK-NEXT: [[SH:%.*]] = lshr i64 [[ADD:%.*]], 32 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i64 [[SH]] to i32 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i64 [[ADD]] to i32 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i32 [[CONV1_I]], 31 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i32 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[ADD:%.*]], 2147483648 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i64 [[TMP1]], 4294967296 ; CHECK-NEXT: ret i1 [[CMP_NOT_I]] ; %sh = lshr i64 %add, 32 @@ -113,11 +104,10 @@ define i1 @extrause_a(i16 %add) { ; CHECK-LABEL: @extrause_a( -; CHECK-NEXT: [[SH:%.*]] = lshr i16 [[ADD:%.*]], 8 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i16 [[SH]] to i8 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD]] to i8 +; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD:%.*]] to i8 ; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i8 [[CONV1_I]], 7 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i8 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[TMP1:%.*]] = add i16 [[ADD]], 128 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i16 [[TMP1]], 256 ; CHECK-NEXT: call void @use(i8 [[SHR2_I]]) ; CHECK-NEXT: ret i1 [[CMP_NOT_I]] ; @@ -134,9 +124,8 @@ ; CHECK-LABEL: @extrause_l( ; CHECK-NEXT: [[SH:%.*]] = lshr i16 [[ADD:%.*]], 8 ; CHECK-NEXT: [[CONV_I:%.*]] = trunc i16 [[SH]] to i8 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD]] to i8 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i8 [[CONV1_I]], 7 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i8 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[TMP1:%.*]] = add i16 [[ADD]], 128 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i16 [[TMP1]], 256 ; CHECK-NEXT: call void @use(i8 [[CONV_I]]) ; CHECK-NEXT: ret i1 [[CMP_NOT_I]] ; Index: llvm/test/Transforms/InstCombine/truncating-saturate.ll =================================================================== --- llvm/test/Transforms/InstCombine/truncating-saturate.ll +++ llvm/test/Transforms/InstCombine/truncating-saturate.ll @@ -7,11 +7,9 @@ define i8 @testi16i8(i16 %add) { ; CHECK-LABEL: @testi16i8( -; CHECK-NEXT: [[SH:%.*]] = lshr i16 [[ADD:%.*]], 8 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i16 [[SH]] to i8 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD]] to i8 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i8 [[CONV1_I]], 7 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i8 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD:%.*]] to i8 +; CHECK-NEXT: [[TMP1:%.*]] = add i16 [[ADD]], 128 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i16 [[TMP1]], 256 ; CHECK-NEXT: [[SHR4_I:%.*]] = ashr i16 [[ADD]], 15 ; CHECK-NEXT: [[CONV5_I:%.*]] = trunc i16 [[SHR4_I]] to i8 ; CHECK-NEXT: [[XOR_I:%.*]] = xor i8 [[CONV5_I]], 127 @@ -32,11 +30,9 @@ define i32 @testi64i32(i64 %add) { ; CHECK-LABEL: @testi64i32( -; CHECK-NEXT: [[SH:%.*]] = lshr i64 [[ADD:%.*]], 32 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i64 [[SH]] to i32 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i64 [[ADD]] to i32 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i32 [[CONV1_I]], 31 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i32 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i64 [[ADD:%.*]] to i32 +; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[ADD]], 2147483648 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i64 [[TMP1]], 4294967296 ; CHECK-NEXT: [[SHR4_I:%.*]] = ashr i64 [[ADD]], 63 ; CHECK-NEXT: [[CONV5_I:%.*]] = trunc i64 [[SHR4_I]] to i32 ; CHECK-NEXT: [[XOR_I:%.*]] = xor i32 [[CONV5_I]], 2147483647 @@ -60,11 +56,9 @@ ; CHECK-NEXT: [[SA:%.*]] = sext i32 [[A:%.*]] to i64 ; CHECK-NEXT: [[SB:%.*]] = sext i32 [[B:%.*]] to i64 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[SA]], [[SB]] -; CHECK-NEXT: [[SH:%.*]] = lshr i64 [[ADD]], 32 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i64 [[SH]] to i32 ; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i64 [[ADD]] to i32 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i32 [[CONV1_I]], 31 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i32 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[TMP1:%.*]] = add nsw i64 [[ADD]], 2147483648 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i64 [[TMP1]], 4294967296 ; CHECK-NEXT: [[SHR4_I:%.*]] = ashr i64 [[ADD]], 63 ; CHECK-NEXT: [[CONV5_I:%.*]] = trunc i64 [[SHR4_I]] to i32 ; CHECK-NEXT: [[XOR_I:%.*]] = xor i32 [[CONV5_I]], 2147483647 @@ -88,11 +82,9 @@ define <4 x i8> @testv4i16i8(<4 x i16> %add) { ; CHECK-LABEL: @testv4i16i8( -; CHECK-NEXT: [[SH:%.*]] = lshr <4 x i16> [[ADD:%.*]], -; CHECK-NEXT: [[CONV_I:%.*]] = trunc <4 x i16> [[SH]] to <4 x i8> -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc <4 x i16> [[ADD]] to <4 x i8> -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr <4 x i8> [[CONV1_I]], -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq <4 x i8> [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[CONV1_I:%.*]] = trunc <4 x i16> [[ADD:%.*]] to <4 x i8> +; CHECK-NEXT: [[TMP1:%.*]] = add <4 x i16> [[ADD]], +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult <4 x i16> [[TMP1]], ; CHECK-NEXT: [[SHR4_I:%.*]] = ashr <4 x i16> [[ADD]], ; CHECK-NEXT: [[CONV5_I:%.*]] = trunc <4 x i16> [[SHR4_I]] to <4 x i8> ; CHECK-NEXT: [[XOR_I:%.*]] = xor <4 x i8> [[CONV5_I]], @@ -116,11 +108,9 @@ ; CHECK-NEXT: [[SA:%.*]] = sext <4 x i8> [[A:%.*]] to <4 x i16> ; CHECK-NEXT: [[SB:%.*]] = sext <4 x i8> [[B:%.*]] to <4 x i16> ; CHECK-NEXT: [[ADD:%.*]] = add nsw <4 x i16> [[SA]], [[SB]] -; CHECK-NEXT: [[SH:%.*]] = lshr <4 x i16> [[ADD]], -; CHECK-NEXT: [[CONV_I:%.*]] = trunc <4 x i16> [[SH]] to <4 x i8> ; CHECK-NEXT: [[CONV1_I:%.*]] = trunc <4 x i16> [[ADD]] to <4 x i8> -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr <4 x i8> [[CONV1_I]], -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq <4 x i8> [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[TMP1:%.*]] = add nsw <4 x i16> [[ADD]], +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult <4 x i16> [[TMP1]], ; CHECK-NEXT: [[SHR4_I:%.*]] = ashr <4 x i16> [[ADD]], ; CHECK-NEXT: [[CONV5_I:%.*]] = trunc <4 x i16> [[SHR4_I]] to <4 x i8> ; CHECK-NEXT: [[XOR_I:%.*]] = xor <4 x i8> [[CONV5_I]], @@ -144,11 +134,9 @@ define i8 @testi16i8_revcmp(i16 %add) { ; CHECK-LABEL: @testi16i8_revcmp( -; CHECK-NEXT: [[SH:%.*]] = lshr i16 [[ADD:%.*]], 8 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i16 [[SH]] to i8 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD]] to i8 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i8 [[CONV1_I]], 7 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i8 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD:%.*]] to i8 +; CHECK-NEXT: [[TMP1:%.*]] = add i16 [[ADD]], 128 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i16 [[TMP1]], 256 ; CHECK-NEXT: [[SHR4_I:%.*]] = ashr i16 [[ADD]], 15 ; CHECK-NEXT: [[CONV5_I:%.*]] = trunc i16 [[SHR4_I]] to i8 ; CHECK-NEXT: [[XOR_I:%.*]] = xor i8 [[CONV5_I]], 127 @@ -169,11 +157,9 @@ define i8 @testi16i8_revselect(i16 %add) { ; CHECK-LABEL: @testi16i8_revselect( -; CHECK-NEXT: [[SH:%.*]] = lshr i16 [[ADD:%.*]], 8 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i16 [[SH]] to i8 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD]] to i8 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i8 [[CONV1_I]], 7 -; CHECK-NEXT: [[CMP_NOT_I_NOT:%.*]] = icmp eq i8 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD:%.*]] to i8 +; CHECK-NEXT: [[TMP1:%.*]] = add i16 [[ADD]], 128 +; CHECK-NEXT: [[CMP_NOT_I_NOT:%.*]] = icmp ult i16 [[TMP1]], 256 ; CHECK-NEXT: [[SHR4_I:%.*]] = ashr i16 [[ADD]], 15 ; CHECK-NEXT: [[CONV5_I:%.*]] = trunc i16 [[SHR4_I]] to i8 ; CHECK-NEXT: [[XOR_I:%.*]] = xor i8 [[CONV5_I]], 127 @@ -271,11 +257,9 @@ define i8 @badimm3(i16 %add) { ; CHECK-LABEL: @badimm3( -; CHECK-NEXT: [[SH:%.*]] = lshr i16 [[ADD:%.*]], 8 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i16 [[SH]] to i8 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD]] to i8 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i8 [[CONV1_I]], 7 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i8 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD:%.*]] to i8 +; CHECK-NEXT: [[TMP1:%.*]] = add i16 [[ADD]], 128 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i16 [[TMP1]], 256 ; CHECK-NEXT: [[SHR4_I:%.*]] = ashr i16 [[ADD]], 14 ; CHECK-NEXT: [[CONV5_I:%.*]] = trunc i16 [[SHR4_I]] to i8 ; CHECK-NEXT: [[XOR_I:%.*]] = xor i8 [[CONV5_I]], 127 @@ -296,11 +280,9 @@ define i8 @badimm4(i16 %add) { ; CHECK-LABEL: @badimm4( -; CHECK-NEXT: [[SH:%.*]] = lshr i16 [[ADD:%.*]], 8 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i16 [[SH]] to i8 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD]] to i8 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i8 [[CONV1_I]], 7 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i8 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i16 [[ADD:%.*]] to i8 +; CHECK-NEXT: [[TMP1:%.*]] = add i16 [[ADD]], 128 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i16 [[TMP1]], 256 ; CHECK-NEXT: [[SHR4_I:%.*]] = ashr i16 [[ADD]], 15 ; CHECK-NEXT: [[CONV5_I:%.*]] = trunc i16 [[SHR4_I]] to i8 ; CHECK-NEXT: [[XOR_I:%.*]] = xor i8 [[CONV5_I]], 126 @@ -323,11 +305,9 @@ define i32 @oneusexor(i64 %add) { ; CHECK-LABEL: @oneusexor( -; CHECK-NEXT: [[SH:%.*]] = lshr i64 [[ADD:%.*]], 32 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i64 [[SH]] to i32 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i64 [[ADD]] to i32 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i32 [[CONV1_I]], 31 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i32 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i64 [[ADD:%.*]] to i32 +; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[ADD]], 2147483648 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i64 [[TMP1]], 4294967296 ; CHECK-NEXT: [[SHR4_I:%.*]] = ashr i64 [[ADD]], 63 ; CHECK-NEXT: [[CONV5_I:%.*]] = trunc i64 [[SHR4_I]] to i32 ; CHECK-NEXT: [[XOR_I:%.*]] = xor i32 [[CONV5_I]], 2147483647 @@ -350,11 +330,9 @@ define i32 @oneuseconv(i64 %add) { ; CHECK-LABEL: @oneuseconv( -; CHECK-NEXT: [[SH:%.*]] = lshr i64 [[ADD:%.*]], 32 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i64 [[SH]] to i32 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i64 [[ADD]] to i32 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i32 [[CONV1_I]], 31 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i32 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i64 [[ADD:%.*]] to i32 +; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[ADD]], 2147483648 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i64 [[TMP1]], 4294967296 ; CHECK-NEXT: [[SHR4_I:%.*]] = ashr i64 [[ADD]], 63 ; CHECK-NEXT: [[CONV5_I:%.*]] = trunc i64 [[SHR4_I]] to i32 ; CHECK-NEXT: [[XOR_I:%.*]] = xor i32 [[CONV5_I]], 2147483647 @@ -377,11 +355,9 @@ define i32 @oneusecmp(i64 %add) { ; CHECK-LABEL: @oneusecmp( -; CHECK-NEXT: [[SH:%.*]] = lshr i64 [[ADD:%.*]], 32 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i64 [[SH]] to i32 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i64 [[ADD]] to i32 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i32 [[CONV1_I]], 31 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i32 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i64 [[ADD:%.*]] to i32 +; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[ADD]], 2147483648 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i64 [[TMP1]], 4294967296 ; CHECK-NEXT: [[SHR4_I:%.*]] = ashr i64 [[ADD]], 63 ; CHECK-NEXT: [[CONV5_I:%.*]] = trunc i64 [[SHR4_I]] to i32 ; CHECK-NEXT: [[XOR_I:%.*]] = xor i32 [[CONV5_I]], 2147483647 @@ -404,11 +380,9 @@ define i32 @oneuseboth(i64 %add) { ; CHECK-LABEL: @oneuseboth( -; CHECK-NEXT: [[SH:%.*]] = lshr i64 [[ADD:%.*]], 32 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i64 [[SH]] to i32 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i64 [[ADD]] to i32 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i32 [[CONV1_I]], 31 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i32 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i64 [[ADD:%.*]] to i32 +; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[ADD]], 2147483648 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i64 [[TMP1]], 4294967296 ; CHECK-NEXT: [[SHR4_I:%.*]] = ashr i64 [[ADD]], 63 ; CHECK-NEXT: [[CONV5_I:%.*]] = trunc i64 [[SHR4_I]] to i32 ; CHECK-NEXT: [[XOR_I:%.*]] = xor i32 [[CONV5_I]], 2147483647 @@ -433,11 +407,9 @@ define i32 @oneusethree(i64 %add) { ; CHECK-LABEL: @oneusethree( -; CHECK-NEXT: [[SH:%.*]] = lshr i64 [[ADD:%.*]], 32 -; CHECK-NEXT: [[CONV_I:%.*]] = trunc i64 [[SH]] to i32 -; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i64 [[ADD]] to i32 -; CHECK-NEXT: [[SHR2_I:%.*]] = ashr i32 [[CONV1_I]], 31 -; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp eq i32 [[SHR2_I]], [[CONV_I]] +; CHECK-NEXT: [[CONV1_I:%.*]] = trunc i64 [[ADD:%.*]] to i32 +; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[ADD]], 2147483648 +; CHECK-NEXT: [[CMP_NOT_I:%.*]] = icmp ult i64 [[TMP1]], 4294967296 ; CHECK-NEXT: [[SHR4_I:%.*]] = ashr i64 [[ADD]], 63 ; CHECK-NEXT: [[CONV5_I:%.*]] = trunc i64 [[SHR4_I]] to i32 ; CHECK-NEXT: [[XOR_I:%.*]] = xor i32 [[CONV5_I]], 2147483647