Index: llvm/include/llvm/Transforms/InstCombine/InstCombineWorklist.h =================================================================== --- llvm/include/llvm/Transforms/InstCombine/InstCombineWorklist.h +++ llvm/include/llvm/Transforms/InstCombine/InstCombineWorklist.h @@ -26,6 +26,10 @@ class InstCombineWorklist { SmallVector Worklist; DenseMap WorklistMap; + /// These instructions will be added in reverse order after the current + /// combined has finished. This means that these instructions will be visited + /// in the order they have been added. + SmallSetVector Deferred; public: InstCombineWorklist() = default; @@ -52,6 +56,17 @@ Add(I); } + void AddDeferred(Instruction *I) { + if (Deferred.insert(I)) + LLVM_DEBUG(dbgs() << "IC: ADD DEFERRED: " << *I << '\n'); + } + + void AddDeferredInstructions() { + for (Instruction *I : reverse(Deferred)) + Add(I); + Deferred.clear(); + } + /// AddInitialGroup - Add the specified batch of stuff in reverse order. /// which should only be done when the worklist is empty and when the group /// has no duplicates. @@ -77,6 +92,7 @@ Worklist[It->second] = nullptr; WorklistMap.erase(It); + Deferred.remove(I); } Instruction *RemoveOne() { @@ -99,6 +115,7 @@ /// the map if it is large. void Zap() { assert(WorklistMap.empty() && "Worklist empty, but map not?"); + assert(Deferred.empty() && "Deferred instructions left over"); // Do an explicit clear, this shrinks the map if needed. WorklistMap.clear(); Index: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp =================================================================== --- llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -3432,6 +3432,7 @@ } MadeIRChange = true; } + Worklist.AddDeferredInstructions(); } Worklist.Zap(); @@ -3597,7 +3598,7 @@ IRBuilder Builder( F.getContext(), TargetFolder(DL), IRBuilderCallbackInserter([&Worklist, &AC](Instruction *I) { - Worklist.Add(I); + Worklist.AddDeferred(I); if (match(I, m_Intrinsic())) AC.registerAssumption(cast(I)); })); Index: llvm/test/Transforms/InstCombine/canonicalize-clamp-like-pattern-between-negative-and-positive-thresholds.ll =================================================================== --- llvm/test/Transforms/InstCombine/canonicalize-clamp-like-pattern-between-negative-and-positive-thresholds.ll +++ llvm/test/Transforms/InstCombine/canonicalize-clamp-like-pattern-between-negative-and-positive-thresholds.ll @@ -26,9 +26,9 @@ define i32 @t0_ult_slt_128(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t0_ult_slt_128( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], -16 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 128 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 127 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp slt i32 %x, 128 @@ -41,9 +41,9 @@ define i32 @t1_ult_slt_0(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t1_ult_slt_0( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], -16 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 128 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 127 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp slt i32 %x, -16 @@ -57,9 +57,9 @@ define i32 @t2_ult_sgt_128(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t2_ult_sgt_128( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], -16 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 128 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 127 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp sgt i32 %x, 127 @@ -72,9 +72,9 @@ define i32 @t3_ult_sgt_neg1(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t3_ult_sgt_neg1( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], -16 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 128 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 127 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp sgt i32 %x, -17 @@ -88,9 +88,9 @@ define i32 @t4_ugt_slt_128(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t4_ugt_slt_128( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], -16 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 128 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 127 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp slt i32 %x, 128 @@ -103,9 +103,9 @@ define i32 @t5_ugt_slt_0(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t5_ugt_slt_0( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], -16 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 128 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 127 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp slt i32 %x, -16 @@ -119,9 +119,9 @@ define i32 @t6_ugt_sgt_128(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t6_ugt_sgt_128( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], -16 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 128 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 127 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp sgt i32 %x, 127 @@ -134,9 +134,9 @@ define i32 @t7_ugt_sgt_neg1(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t7_ugt_sgt_neg1( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], -16 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 128 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 127 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp sgt i32 %x, -17 @@ -198,9 +198,9 @@ ; CHECK-NEXT: [[T0:%.*]] = icmp slt i32 [[X:%.*]], 64 ; CHECK-NEXT: call void @use1(i1 [[T0]]) ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X]], -16 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 128 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 127 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp slt i32 %x, 64 @@ -236,9 +236,9 @@ ; CHECK-NEXT: [[T2:%.*]] = add i32 [[X:%.*]], 16 ; CHECK-NEXT: call void @use32(i32 [[T2]]) ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X]], -16 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 128 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 127 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp slt i32 %x, 64 @@ -407,9 +407,9 @@ define <2 x i32> @t20_ult_slt_vec_splat(<2 x i32> %x, <2 x i32> %replacement_low, <2 x i32> %replacement_high) { ; CHECK-LABEL: @t20_ult_slt_vec_splat( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <2 x i32> [[X:%.*]], -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt <2 x i32> [[X]], +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt <2 x i32> [[X]], ; CHECK-NEXT: [[TMP3:%.*]] = select <2 x i1> [[TMP1]], <2 x i32> [[REPLACEMENT_LOW:%.*]], <2 x i32> [[X]] -; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[TMP2]], <2 x i32> [[TMP3]], <2 x i32> [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[TMP2]], <2 x i32> [[REPLACEMENT_HIGH:%.*]], <2 x i32> [[TMP3]] ; CHECK-NEXT: ret <2 x i32> [[R]] ; %t0 = icmp slt <2 x i32> %x, @@ -422,9 +422,9 @@ define <2 x i32> @t21_ult_slt_vec_nonsplat(<2 x i32> %x, <2 x i32> %replacement_low, <2 x i32> %replacement_high) { ; CHECK-LABEL: @t21_ult_slt_vec_nonsplat( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <2 x i32> [[X:%.*]], -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt <2 x i32> [[X]], +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt <2 x i32> [[X]], ; CHECK-NEXT: [[TMP3:%.*]] = select <2 x i1> [[TMP1]], <2 x i32> [[REPLACEMENT_LOW:%.*]], <2 x i32> [[X]] -; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[TMP2]], <2 x i32> [[TMP3]], <2 x i32> [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[TMP2]], <2 x i32> [[REPLACEMENT_HIGH:%.*]], <2 x i32> [[TMP3]] ; CHECK-NEXT: ret <2 x i32> [[R]] ; %t0 = icmp slt <2 x i32> %x, @@ -464,9 +464,9 @@ ; CHECK-NEXT: [[T0:%.*]] = icmp sge <2 x i32> [[X:%.*]], ; CHECK-NEXT: call void @use2xi1(<2 x i1> [[T0]]) ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <2 x i32> [[X]], -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt <2 x i32> [[X]], +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt <2 x i32> [[X]], ; CHECK-NEXT: [[TMP3:%.*]] = select <2 x i1> [[TMP1]], <2 x i32> [[REPLACEMENT_LOW:%.*]], <2 x i32> [[X]] -; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[TMP2]], <2 x i32> [[TMP3]], <2 x i32> [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[TMP2]], <2 x i32> [[REPLACEMENT_HIGH:%.*]], <2 x i32> [[TMP3]] ; CHECK-NEXT: ret <2 x i32> [[R]] ; %t0 = icmp sge <2 x i32> %x, Index: llvm/test/Transforms/InstCombine/canonicalize-clamp-like-pattern-between-zero-and-positive-threshold.ll =================================================================== --- llvm/test/Transforms/InstCombine/canonicalize-clamp-like-pattern-between-zero-and-positive-threshold.ll +++ llvm/test/Transforms/InstCombine/canonicalize-clamp-like-pattern-between-zero-and-positive-threshold.ll @@ -26,9 +26,9 @@ define i32 @t0_ult_slt_65536(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t0_ult_slt_65536( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], 0 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 65536 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 65535 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp slt i32 %x, 65536 @@ -40,9 +40,9 @@ define i32 @t1_ult_slt_0(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t1_ult_slt_0( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], 0 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 65536 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 65535 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp slt i32 %x, 0 @@ -55,9 +55,9 @@ define i32 @t2_ult_sgt_65536(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t2_ult_sgt_65536( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], 0 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 65536 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 65535 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp sgt i32 %x, 65535 @@ -69,9 +69,9 @@ define i32 @t3_ult_sgt_neg1(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t3_ult_sgt_neg1( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], 0 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 65536 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 65535 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp sgt i32 %x, -1 @@ -84,9 +84,9 @@ define i32 @t4_ugt_slt_65536(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t4_ugt_slt_65536( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], 0 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 65536 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 65535 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp slt i32 %x, 65536 @@ -98,9 +98,9 @@ define i32 @t5_ugt_slt_0(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t5_ugt_slt_0( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], 0 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 65536 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 65535 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp slt i32 %x, 0 @@ -113,9 +113,9 @@ define i32 @t6_ugt_sgt_65536(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t6_ugt_sgt_65536( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], 0 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 65536 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 65535 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp sgt i32 %x, 65535 @@ -127,9 +127,9 @@ define i32 @t7_ugt_sgt_neg1(i32 %x, i32 %replacement_low, i32 %replacement_high) { ; CHECK-LABEL: @t7_ugt_sgt_neg1( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], 0 -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[X]], 65536 +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[X]], 65535 ; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i32 [[REPLACEMENT_LOW:%.*]], i32 [[X]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i32 [[REPLACEMENT_HIGH:%.*]], i32 [[TMP3]] ; CHECK-NEXT: ret i32 [[R]] ; %t0 = icmp sgt i32 %x, -1 @@ -312,9 +312,9 @@ define <2 x i32> @t17_ult_slt_vec_splat(<2 x i32> %x, <2 x i32> %replacement_low, <2 x i32> %replacement_high) { ; CHECK-LABEL: @t17_ult_slt_vec_splat( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <2 x i32> [[X:%.*]], zeroinitializer -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt <2 x i32> [[X]], +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt <2 x i32> [[X]], ; CHECK-NEXT: [[TMP3:%.*]] = select <2 x i1> [[TMP1]], <2 x i32> [[REPLACEMENT_LOW:%.*]], <2 x i32> [[X]] -; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[TMP2]], <2 x i32> [[TMP3]], <2 x i32> [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[TMP2]], <2 x i32> [[REPLACEMENT_HIGH:%.*]], <2 x i32> [[TMP3]] ; CHECK-NEXT: ret <2 x i32> [[R]] ; %t0 = icmp slt <2 x i32> %x, @@ -326,9 +326,9 @@ define <2 x i32> @t18_ult_slt_vec_nonsplat(<2 x i32> %x, <2 x i32> %replacement_low, <2 x i32> %replacement_high) { ; CHECK-LABEL: @t18_ult_slt_vec_nonsplat( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <2 x i32> [[X:%.*]], zeroinitializer -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt <2 x i32> [[X]], +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt <2 x i32> [[X]], ; CHECK-NEXT: [[TMP3:%.*]] = select <2 x i1> [[TMP1]], <2 x i32> [[REPLACEMENT_LOW:%.*]], <2 x i32> [[X]] -; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[TMP2]], <2 x i32> [[TMP3]], <2 x i32> [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[TMP2]], <2 x i32> [[REPLACEMENT_HIGH:%.*]], <2 x i32> [[TMP3]] ; CHECK-NEXT: ret <2 x i32> [[R]] ; %t0 = icmp slt <2 x i32> %x, @@ -341,9 +341,9 @@ define <3 x i32> @t19_ult_slt_vec_undef0(<3 x i32> %x, <3 x i32> %replacement_low, <3 x i32> %replacement_high) { ; CHECK-LABEL: @t19_ult_slt_vec_undef0( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <3 x i32> [[X:%.*]], zeroinitializer -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt <3 x i32> [[X]], +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt <3 x i32> [[X]], ; CHECK-NEXT: [[TMP3:%.*]] = select <3 x i1> [[TMP1]], <3 x i32> [[REPLACEMENT_LOW:%.*]], <3 x i32> [[X]] -; CHECK-NEXT: [[R:%.*]] = select <3 x i1> [[TMP2]], <3 x i32> [[TMP3]], <3 x i32> [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select <3 x i1> [[TMP2]], <3 x i32> [[REPLACEMENT_HIGH:%.*]], <3 x i32> [[TMP3]] ; CHECK-NEXT: ret <3 x i32> [[R]] ; %t0 = icmp slt <3 x i32> %x, @@ -355,9 +355,9 @@ define <3 x i32> @t20_ult_slt_vec_undef1(<3 x i32> %x, <3 x i32> %replacement_low, <3 x i32> %replacement_high) { ; CHECK-LABEL: @t20_ult_slt_vec_undef1( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <3 x i32> [[X:%.*]], zeroinitializer -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt <3 x i32> [[X]], +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt <3 x i32> [[X]], ; CHECK-NEXT: [[TMP3:%.*]] = select <3 x i1> [[TMP1]], <3 x i32> [[REPLACEMENT_LOW:%.*]], <3 x i32> [[X]] -; CHECK-NEXT: [[R:%.*]] = select <3 x i1> [[TMP2]], <3 x i32> [[TMP3]], <3 x i32> [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select <3 x i1> [[TMP2]], <3 x i32> [[REPLACEMENT_HIGH:%.*]], <3 x i32> [[TMP3]] ; CHECK-NEXT: ret <3 x i32> [[R]] ; %t0 = icmp slt <3 x i32> %x, @@ -369,9 +369,9 @@ define <3 x i32> @t21_ult_slt_vec_undef2(<3 x i32> %x, <3 x i32> %replacement_low, <3 x i32> %replacement_high) { ; CHECK-LABEL: @t21_ult_slt_vec_undef2( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <3 x i32> [[X:%.*]], zeroinitializer -; CHECK-NEXT: [[TMP2:%.*]] = icmp slt <3 x i32> [[X]], +; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt <3 x i32> [[X]], ; CHECK-NEXT: [[TMP3:%.*]] = select <3 x i1> [[TMP1]], <3 x i32> [[REPLACEMENT_LOW:%.*]], <3 x i32> [[X]] -; CHECK-NEXT: [[R:%.*]] = select <3 x i1> [[TMP2]], <3 x i32> [[TMP3]], <3 x i32> [[REPLACEMENT_HIGH:%.*]] +; CHECK-NEXT: [[R:%.*]] = select <3 x i1> [[TMP2]], <3 x i32> [[REPLACEMENT_HIGH:%.*]], <3 x i32> [[TMP3]] ; CHECK-NEXT: ret <3 x i32> [[R]] ; %t0 = icmp slt <3 x i32> %x, Index: llvm/test/Transforms/InstCombine/demorgan.ll =================================================================== --- llvm/test/Transforms/InstCombine/demorgan.ll +++ llvm/test/Transforms/InstCombine/demorgan.ll @@ -5,7 +5,7 @@ define i43 @demorgan_or_apint1(i43 %A, i43 %B) { ; CHECK-LABEL: @demorgan_or_apint1( -; CHECK-NEXT: [[C_DEMORGAN:%.*]] = and i43 %A, %B +; CHECK-NEXT: [[C_DEMORGAN:%.*]] = and i43 [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: [[C:%.*]] = xor i43 [[C_DEMORGAN]], -1 ; CHECK-NEXT: ret i43 [[C]] ; @@ -19,7 +19,7 @@ define i129 @demorgan_or_apint2(i129 %A, i129 %B) { ; CHECK-LABEL: @demorgan_or_apint2( -; CHECK-NEXT: [[C_DEMORGAN:%.*]] = and i129 %A, %B +; CHECK-NEXT: [[C_DEMORGAN:%.*]] = and i129 [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: [[C:%.*]] = xor i129 [[C_DEMORGAN]], -1 ; CHECK-NEXT: ret i129 [[C]] ; @@ -33,7 +33,7 @@ define i477 @demorgan_and_apint1(i477 %A, i477 %B) { ; CHECK-LABEL: @demorgan_and_apint1( -; CHECK-NEXT: [[C_DEMORGAN:%.*]] = or i477 %A, %B +; CHECK-NEXT: [[C_DEMORGAN:%.*]] = or i477 [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: [[C:%.*]] = xor i477 [[C_DEMORGAN]], -1 ; CHECK-NEXT: ret i477 [[C]] ; @@ -47,7 +47,7 @@ define i129 @demorgan_and_apint2(i129 %A, i129 %B) { ; CHECK-LABEL: @demorgan_and_apint2( -; CHECK-NEXT: [[C_DEMORGAN:%.*]] = or i129 %A, %B +; CHECK-NEXT: [[C_DEMORGAN:%.*]] = or i129 [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: [[C:%.*]] = xor i129 [[C_DEMORGAN]], -1 ; CHECK-NEXT: ret i129 [[C]] ; @@ -61,7 +61,7 @@ define i65 @demorgan_and_apint3(i65 %A, i65 %B) { ; CHECK-LABEL: @demorgan_and_apint3( -; CHECK-NEXT: [[C_DEMORGAN:%.*]] = or i65 %A, %B +; CHECK-NEXT: [[C_DEMORGAN:%.*]] = or i65 [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: [[C:%.*]] = xor i65 [[C_DEMORGAN]], -1 ; CHECK-NEXT: ret i65 [[C]] ; @@ -75,7 +75,7 @@ define i66 @demorgan_and_apint4(i66 %A, i66 %B) { ; CHECK-LABEL: @demorgan_and_apint4( -; CHECK-NEXT: [[C_DEMORGAN:%.*]] = or i66 %A, %B +; CHECK-NEXT: [[C_DEMORGAN:%.*]] = or i66 [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: [[C:%.*]] = xor i66 [[C_DEMORGAN]], -1 ; CHECK-NEXT: ret i66 [[C]] ; @@ -89,7 +89,7 @@ define i47 @demorgan_and_apint5(i47 %A, i47 %B) { ; CHECK-LABEL: @demorgan_and_apint5( -; CHECK-NEXT: [[C_DEMORGAN:%.*]] = or i47 %A, %B +; CHECK-NEXT: [[C_DEMORGAN:%.*]] = or i47 [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: [[C:%.*]] = xor i47 [[C_DEMORGAN]], -1 ; CHECK-NEXT: ret i47 [[C]] ; @@ -104,7 +104,7 @@ define i32 @test3(i32 %A, i32 %B) { ; CHECK-LABEL: @test3( -; CHECK-NEXT: [[C_DEMORGAN:%.*]] = or i32 %A, %B +; CHECK-NEXT: [[C_DEMORGAN:%.*]] = or i32 [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i32 [[C_DEMORGAN]] ; %nota = xor i32 %A, -1 @@ -119,7 +119,7 @@ define i32 @test4(i32 %A) { ; CHECK-LABEL: @test4( -; CHECK-NEXT: [[NOTC1:%.*]] = or i32 %A, -6 +; CHECK-NEXT: [[NOTC1:%.*]] = or i32 [[A:%.*]], -6 ; CHECK-NEXT: ret i32 [[NOTC1]] ; %nota = xor i32 %A, -1 @@ -133,7 +133,7 @@ define i32 @test5(i32 %A, i32 %B) { ; CHECK-LABEL: @test5( -; CHECK-NEXT: [[C_DEMORGAN:%.*]] = and i32 %A, %B +; CHECK-NEXT: [[C_DEMORGAN:%.*]] = and i32 [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i32 [[C_DEMORGAN]] ; %nota = xor i32 %A, -1 @@ -148,7 +148,7 @@ define i47 @test3_apint(i47 %A, i47 %B) { ; CHECK-LABEL: @test3_apint( -; CHECK-NEXT: [[C_DEMORGAN:%.*]] = or i47 %A, %B +; CHECK-NEXT: [[C_DEMORGAN:%.*]] = or i47 [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i47 [[C_DEMORGAN]] ; %nota = xor i47 %A, -1 @@ -162,7 +162,7 @@ define i61 @test4_apint(i61 %A) { ; CHECK-LABEL: @test4_apint( -; CHECK-NEXT: [[NOTA:%.*]] = and i61 %A, 5 +; CHECK-NEXT: [[NOTA:%.*]] = and i61 [[A:%.*]], 5 ; CHECK-NEXT: [[C:%.*]] = xor i61 [[NOTA]], 5 ; CHECK-NEXT: ret i61 [[C]] ; @@ -176,7 +176,7 @@ define i71 @test5_apint(i71 %A, i71 %B) { ; CHECK-LABEL: @test5_apint( -; CHECK-NEXT: [[C_DEMORGAN:%.*]] = and i71 %A, %B +; CHECK-NEXT: [[C_DEMORGAN:%.*]] = and i71 [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i71 [[C_DEMORGAN]] ; %nota = xor i71 %A, -1 @@ -190,8 +190,8 @@ define i8 @demorgan_nand(i8 %A, i8 %B) { ; CHECK-LABEL: @demorgan_nand( -; CHECK-NEXT: [[B_NOT:%.*]] = xor i8 %B, -1 -; CHECK-NEXT: [[NOTC:%.*]] = or i8 [[B_NOT]], %A +; CHECK-NEXT: [[B_NOT:%.*]] = xor i8 [[B:%.*]], -1 +; CHECK-NEXT: [[NOTC:%.*]] = or i8 [[B_NOT]], [[A:%.*]] ; CHECK-NEXT: ret i8 [[NOTC]] ; %notx = xor i8 %A, -1 @@ -204,8 +204,8 @@ define i7 @demorgan_nand_apint1(i7 %A, i7 %B) { ; CHECK-LABEL: @demorgan_nand_apint1( -; CHECK-NEXT: [[B_NOT:%.*]] = xor i7 %B, -1 -; CHECK-NEXT: [[NOTC:%.*]] = or i7 [[B_NOT]], %A +; CHECK-NEXT: [[B_NOT:%.*]] = xor i7 [[B:%.*]], -1 +; CHECK-NEXT: [[NOTC:%.*]] = or i7 [[B_NOT]], [[A:%.*]] ; CHECK-NEXT: ret i7 [[NOTC]] ; %nota = xor i7 %A, -1 @@ -218,8 +218,8 @@ define i117 @demorgan_nand_apint2(i117 %A, i117 %B) { ; CHECK-LABEL: @demorgan_nand_apint2( -; CHECK-NEXT: [[B_NOT:%.*]] = xor i117 %B, -1 -; CHECK-NEXT: [[NOTC:%.*]] = or i117 [[B_NOT]], %A +; CHECK-NEXT: [[B_NOT:%.*]] = xor i117 [[B:%.*]], -1 +; CHECK-NEXT: [[NOTC:%.*]] = or i117 [[B_NOT]], [[A:%.*]] ; CHECK-NEXT: ret i117 [[NOTC]] ; %nota = xor i117 %A, -1 @@ -232,8 +232,8 @@ define i8 @demorgan_nor(i8 %A, i8 %B) { ; CHECK-LABEL: @demorgan_nor( -; CHECK-NEXT: [[B_NOT:%.*]] = xor i8 %B, -1 -; CHECK-NEXT: [[NOTC:%.*]] = and i8 [[B_NOT]], %A +; CHECK-NEXT: [[B_NOT:%.*]] = xor i8 [[B:%.*]], -1 +; CHECK-NEXT: [[NOTC:%.*]] = and i8 [[B_NOT]], [[A:%.*]] ; CHECK-NEXT: ret i8 [[NOTC]] ; %notx = xor i8 %A, -1 @@ -246,10 +246,10 @@ define i8 @demorgan_nor_use2a(i8 %A, i8 %B) { ; CHECK-LABEL: @demorgan_nor_use2a( -; CHECK-NEXT: [[NOTA:%.*]] = xor i8 %A, -1 +; CHECK-NEXT: [[NOTA:%.*]] = xor i8 [[A:%.*]], -1 ; CHECK-NEXT: [[USE2A:%.*]] = mul i8 [[NOTA]], 23 -; CHECK-NEXT: [[B_NOT:%.*]] = xor i8 %B, -1 -; CHECK-NEXT: [[NOTC:%.*]] = and i8 [[B_NOT]], %A +; CHECK-NEXT: [[B_NOT:%.*]] = xor i8 [[B:%.*]], -1 +; CHECK-NEXT: [[NOTC:%.*]] = and i8 [[B_NOT]], [[A]] ; CHECK-NEXT: [[R:%.*]] = sdiv i8 [[NOTC]], [[USE2A]] ; CHECK-NEXT: ret i8 [[R]] ; @@ -265,9 +265,9 @@ define i8 @demorgan_nor_use2b(i8 %A, i8 %B) { ; CHECK-LABEL: @demorgan_nor_use2b( -; CHECK-NEXT: [[USE2B:%.*]] = mul i8 %B, 23 -; CHECK-NEXT: [[B_NOT:%.*]] = xor i8 %B, -1 -; CHECK-NEXT: [[NOTC:%.*]] = and i8 [[B_NOT]], %A +; CHECK-NEXT: [[USE2B:%.*]] = mul i8 [[B:%.*]], 23 +; CHECK-NEXT: [[B_NOT:%.*]] = xor i8 [[B]], -1 +; CHECK-NEXT: [[NOTC:%.*]] = and i8 [[B_NOT]], [[A:%.*]] ; CHECK-NEXT: [[R:%.*]] = sdiv i8 [[NOTC]], [[USE2B]] ; CHECK-NEXT: ret i8 [[R]] ; @@ -283,8 +283,8 @@ define i8 @demorgan_nor_use2c(i8 %A, i8 %B) { ; CHECK-LABEL: @demorgan_nor_use2c( -; CHECK-NEXT: [[NOTA:%.*]] = xor i8 %A, -1 -; CHECK-NEXT: [[C:%.*]] = or i8 [[NOTA]], %B +; CHECK-NEXT: [[NOTA:%.*]] = xor i8 [[A:%.*]], -1 +; CHECK-NEXT: [[C:%.*]] = or i8 [[NOTA]], [[B:%.*]] ; CHECK-NEXT: [[USE2C:%.*]] = mul i8 [[C]], 23 ; CHECK-NEXT: [[NOTC:%.*]] = xor i8 [[C]], -1 ; CHECK-NEXT: [[R:%.*]] = sdiv i8 [[NOTC]], [[USE2C]] @@ -302,11 +302,11 @@ define i8 @demorgan_nor_use2ab(i8 %A, i8 %B) { ; CHECK-LABEL: @demorgan_nor_use2ab( -; CHECK-NEXT: [[USE2B:%.*]] = mul i8 %B, 23 -; CHECK-NEXT: [[NOTA:%.*]] = xor i8 %A, -1 +; CHECK-NEXT: [[USE2B:%.*]] = mul i8 [[B:%.*]], 23 +; CHECK-NEXT: [[NOTA:%.*]] = xor i8 [[A:%.*]], -1 ; CHECK-NEXT: [[USE2A:%.*]] = mul i8 [[NOTA]], 17 -; CHECK-NEXT: [[B_NOT:%.*]] = xor i8 %B, -1 -; CHECK-NEXT: [[NOTC:%.*]] = and i8 [[B_NOT]], %A +; CHECK-NEXT: [[B_NOT:%.*]] = xor i8 [[B]], -1 +; CHECK-NEXT: [[NOTC:%.*]] = and i8 [[B_NOT]], [[A]] ; CHECK-NEXT: [[R1:%.*]] = sdiv i8 [[NOTC]], [[USE2B]] ; CHECK-NEXT: [[R2:%.*]] = sdiv i8 [[R1]], [[USE2A]] ; CHECK-NEXT: ret i8 [[R2]] @@ -325,9 +325,9 @@ define i8 @demorgan_nor_use2ac(i8 %A, i8 %B) { ; CHECK-LABEL: @demorgan_nor_use2ac( -; CHECK-NEXT: [[NOTA:%.*]] = xor i8 %A, -1 +; CHECK-NEXT: [[NOTA:%.*]] = xor i8 [[A:%.*]], -1 ; CHECK-NEXT: [[USE2A:%.*]] = mul i8 [[NOTA]], 17 -; CHECK-NEXT: [[C:%.*]] = or i8 [[NOTA]], %B +; CHECK-NEXT: [[C:%.*]] = or i8 [[NOTA]], [[B:%.*]] ; CHECK-NEXT: [[USE2C:%.*]] = mul i8 [[C]], 23 ; CHECK-NEXT: [[NOTC:%.*]] = xor i8 [[C]], -1 ; CHECK-NEXT: [[R1:%.*]] = sdiv i8 [[NOTC]], [[USE2C]] @@ -348,9 +348,9 @@ define i8 @demorgan_nor_use2bc(i8 %A, i8 %B) { ; CHECK-LABEL: @demorgan_nor_use2bc( -; CHECK-NEXT: [[USE2B:%.*]] = mul i8 %B, 23 -; CHECK-NEXT: [[NOTA:%.*]] = xor i8 %A, -1 -; CHECK-NEXT: [[C:%.*]] = or i8 [[NOTA]], %B +; CHECK-NEXT: [[USE2B:%.*]] = mul i8 [[B:%.*]], 23 +; CHECK-NEXT: [[NOTA:%.*]] = xor i8 [[A:%.*]], -1 +; CHECK-NEXT: [[C:%.*]] = or i8 [[NOTA]], [[B]] ; CHECK-NEXT: [[USE2C:%.*]] = mul i8 [[C]], 23 ; CHECK-NEXT: [[NOTC:%.*]] = xor i8 [[C]], -1 ; CHECK-NEXT: [[R1:%.*]] = sdiv i8 [[NOTC]], [[USE2C]] @@ -371,7 +371,7 @@ define i32 @demorganize_constant1(i32 %a) { ; CHECK-LABEL: @demorganize_constant1( -; CHECK-NEXT: [[AND:%.*]] = and i32 %a, 15 +; CHECK-NEXT: [[AND:%.*]] = and i32 [[A:%.*]], 15 ; CHECK-NEXT: [[AND1:%.*]] = xor i32 [[AND]], -1 ; CHECK-NEXT: ret i32 [[AND1]] ; @@ -384,7 +384,7 @@ define i32 @demorganize_constant2(i32 %a) { ; CHECK-LABEL: @demorganize_constant2( -; CHECK-NEXT: [[AND:%.*]] = or i32 %a, 15 +; CHECK-NEXT: [[AND:%.*]] = or i32 [[A:%.*]], 15 ; CHECK-NEXT: [[AND1:%.*]] = xor i32 [[AND]], -1 ; CHECK-NEXT: ret i32 [[AND1]] ; @@ -397,7 +397,7 @@ define i32 @demorgan_or_zext(i1 %X, i1 %Y) { ; CHECK-LABEL: @demorgan_or_zext( -; CHECK-NEXT: [[OR1_DEMORGAN:%.*]] = and i1 %X, %Y +; CHECK-NEXT: [[OR1_DEMORGAN:%.*]] = and i1 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[OR1:%.*]] = xor i1 [[OR1_DEMORGAN]], true ; CHECK-NEXT: [[OR:%.*]] = zext i1 [[OR1]] to i32 ; CHECK-NEXT: ret i32 [[OR]] @@ -412,7 +412,7 @@ define i32 @demorgan_and_zext(i1 %X, i1 %Y) { ; CHECK-LABEL: @demorgan_and_zext( -; CHECK-NEXT: [[AND1_DEMORGAN:%.*]] = or i1 %X, %Y +; CHECK-NEXT: [[AND1_DEMORGAN:%.*]] = or i1 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[AND1:%.*]] = xor i1 [[AND1_DEMORGAN]], true ; CHECK-NEXT: [[AND:%.*]] = zext i1 [[AND1]] to i32 ; CHECK-NEXT: ret i32 [[AND]] @@ -427,7 +427,7 @@ define <2 x i32> @demorgan_or_zext_vec(<2 x i1> %X, <2 x i1> %Y) { ; CHECK-LABEL: @demorgan_or_zext_vec( -; CHECK-NEXT: [[OR1_DEMORGAN:%.*]] = and <2 x i1> %X, %Y +; CHECK-NEXT: [[OR1_DEMORGAN:%.*]] = and <2 x i1> [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[OR1:%.*]] = xor <2 x i1> [[OR1_DEMORGAN]], ; CHECK-NEXT: [[OR:%.*]] = zext <2 x i1> [[OR1]] to <2 x i32> ; CHECK-NEXT: ret <2 x i32> [[OR]] @@ -442,7 +442,7 @@ define <2 x i32> @demorgan_and_zext_vec(<2 x i1> %X, <2 x i1> %Y) { ; CHECK-LABEL: @demorgan_and_zext_vec( -; CHECK-NEXT: [[AND1_DEMORGAN:%.*]] = or <2 x i1> %X, %Y +; CHECK-NEXT: [[AND1_DEMORGAN:%.*]] = or <2 x i1> [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[AND1:%.*]] = xor <2 x i1> [[AND1_DEMORGAN]], ; CHECK-NEXT: [[AND:%.*]] = zext <2 x i1> [[AND1]] to <2 x i32> ; CHECK-NEXT: ret <2 x i32> [[AND]] @@ -457,9 +457,9 @@ define i32 @PR28476(i32 %x, i32 %y) { ; CHECK-LABEL: @PR28476( -; CHECK-NEXT: [[CMP0:%.*]] = icmp eq i32 %x, 0 -; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 %y, 0 -; CHECK-NEXT: [[TMP1:%.*]] = or i1 [[CMP1]], [[CMP0]] +; CHECK-NEXT: [[CMP0:%.*]] = icmp eq i32 [[X:%.*]], 0 +; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[Y:%.*]], 0 +; CHECK-NEXT: [[TMP1:%.*]] = or i1 [[CMP0]], [[CMP1]] ; CHECK-NEXT: [[COND:%.*]] = zext i1 [[TMP1]] to i32 ; CHECK-NEXT: ret i32 [[COND]] ; @@ -475,8 +475,8 @@ define i32 @demorgan_plus_and_to_xor(i32 %a, i32 %b) { ; CHECK-LABEL: @demorgan_plus_and_to_xor( -; CHECK-NEXT: [[NOT:%.*]] = xor i32 %b, %a -; CHECK-NEXT: ret i32 [[NOT]] +; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[B:%.*]], [[A:%.*]] +; CHECK-NEXT: ret i32 [[TMP1]] ; %or = or i32 %b, %a %notor = xor i32 %or, -1 @@ -488,8 +488,8 @@ define <4 x i32> @demorgan_plus_and_to_xor_vec(<4 x i32> %a, <4 x i32> %b) { ; CHECK-LABEL: @demorgan_plus_and_to_xor_vec( -; CHECK-NEXT: [[NOT:%.*]] = xor <4 x i32> %a, %b -; CHECK-NEXT: ret <4 x i32> [[NOT]] +; CHECK-NEXT: [[TMP1:%.*]] = xor <4 x i32> [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: ret <4 x i32> [[TMP1]] ; %or = or <4 x i32> %a, %b %notor = xor <4 x i32> %or, < i32 -1, i32 -1, i32 -1, i32 -1 > Index: llvm/test/Transforms/InstCombine/div.ll =================================================================== --- llvm/test/Transforms/InstCombine/div.ll +++ llvm/test/Transforms/InstCombine/div.ll @@ -398,8 +398,9 @@ define i32 @test29(i32 %a) { ; CHECK-LABEL: @test29( -; CHECK-NEXT: [[MUL_LOBIT:%.*]] = and i32 [[A:%.*]], 1 -; CHECK-NEXT: ret i32 [[MUL_LOBIT]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[A:%.*]], -1 +; CHECK-NEXT: [[DIV:%.*]] = zext i1 [[TMP1]] to i32 +; CHECK-NEXT: ret i32 [[DIV]] ; %mul = shl nsw i32 %a, 31 %div = sdiv i32 %mul, -2147483648 Index: llvm/test/Transforms/InstCombine/getelementptr.ll =================================================================== --- llvm/test/Transforms/InstCombine/getelementptr.ll +++ llvm/test/Transforms/InstCombine/getelementptr.ll @@ -217,8 +217,9 @@ ; CHECK-LABEL: @test13_vector2( ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 ; CHECK-NEXT: [[TMP1:%.*]] = shl <2 x i64> [[DOTSPLATINSERT]], -; CHECK-NEXT: [[A_IDX:%.*]] = shufflevector <2 x i64> [[TMP1]], <2 x i64> undef, <2 x i32> zeroinitializer -; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i64> [[A_IDX]], +; CHECK-NEXT: [[TMP2:%.*]] = add <2 x i64> [[TMP1]], +; CHECK-NEXT: [[A_OFFS:%.*]] = shufflevector <2 x i64> [[TMP2]], <2 x i64> undef, <2 x i32> zeroinitializer +; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i64> [[A_OFFS]], zeroinitializer ; CHECK-NEXT: ret <2 x i1> [[C]] ; %A = getelementptr inbounds %S, <2 x %S*> %P, <2 x i64> zeroinitializer, <2 x i32> , i64 %X @@ -232,8 +233,9 @@ ; CHECK-LABEL: @test13_vector3( ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0 ; CHECK-NEXT: [[TMP1:%.*]] = shl <2 x i64> [[DOTSPLATINSERT]], -; CHECK-NEXT: [[A_IDX:%.*]] = shufflevector <2 x i64> [[TMP1]], <2 x i64> undef, <2 x i32> zeroinitializer -; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i64> [[A_IDX]], +; CHECK-NEXT: [[TMP2:%.*]] = add <2 x i64> [[TMP1]], +; CHECK-NEXT: [[A_OFFS:%.*]] = shufflevector <2 x i64> [[TMP2]], <2 x i64> undef, <2 x i32> zeroinitializer +; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i64> [[A_OFFS]], ; CHECK-NEXT: ret <2 x i1> [[C]] ; %A = getelementptr inbounds %S, <2 x %S*> %P, <2 x i64> zeroinitializer, <2 x i32> , i64 %X @@ -302,12 +304,12 @@ @G = external global [3 x i8] define i8* @test14(i32 %idx) { ; CHECK-LABEL: @test14( -; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[IDX:%.*]] to i64 -; CHECK-NEXT: [[TMP:%.*]] = getelementptr [3 x i8], [3 x i8]* @G, i64 0, i64 [[ZEXT]] +; CHECK-NEXT: [[IDX:%.*]] = zext i32 [[IDX:%.*]] to i64 +; CHECK-NEXT: [[TMP:%.*]] = getelementptr [3 x i8], [3 x i8]* @G, i64 0, i64 [[IDX]] ; CHECK-NEXT: ret i8* [[TMP]] ; - %zext = zext i32 %idx to i64 - %tmp = getelementptr i8, i8* getelementptr ([3 x i8], [3 x i8]* @G, i32 0, i32 0), i64 %zext + %idx2 = zext i32 %idx to i64 + %tmp = getelementptr i8, i8* getelementptr ([3 x i8], [3 x i8]* @G, i32 0, i32 0), i64 %idx2 ret i8* %tmp } Index: llvm/test/Transforms/InstCombine/load.ll =================================================================== --- llvm/test/Transforms/InstCombine/load.ll +++ llvm/test/Transforms/InstCombine/load.ll @@ -205,7 +205,6 @@ define void @test16(i8* %x, i8* %a, i8* %b, i8* %c) { ; CHECK-LABEL: @test16( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[C_CAST:%.*]] = bitcast i8* [[C:%.*]] to i32* ; CHECK-NEXT: [[TMP0:%.*]] = bitcast i8* [[X:%.*]] to i32* ; CHECK-NEXT: [[X11:%.*]] = load i32, i32* [[TMP0]], align 4 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast i8* [[A:%.*]] to i32* @@ -216,7 +215,8 @@ ; CHECK-NEXT: [[X22:%.*]] = load i32, i32* [[TMP3]], align 4 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast i8* [[B]] to i32* ; CHECK-NEXT: store i32 [[X22]], i32* [[TMP4]], align 4 -; CHECK-NEXT: store i32 [[X22]], i32* [[C_CAST]], align 4 +; CHECK-NEXT: [[TMP5:%.*]] = bitcast i8* [[C:%.*]] to i32* +; CHECK-NEXT: store i32 [[X22]], i32* [[TMP5]], align 4 ; CHECK-NEXT: ret void ; entry: @@ -240,7 +240,6 @@ define void @test16-vect(i8* %x, i8* %a, i8* %b, i8* %c) { ; CHECK-LABEL: @test16-vect( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[C_CAST:%.*]] = bitcast i8* [[C:%.*]] to i32* ; CHECK-NEXT: [[TMP0:%.*]] = bitcast i8* [[X:%.*]] to i32* ; CHECK-NEXT: [[X11:%.*]] = load i32, i32* [[TMP0]], align 4 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast i8* [[A:%.*]] to i32* @@ -251,7 +250,8 @@ ; CHECK-NEXT: [[X22:%.*]] = load i32, i32* [[TMP3]], align 4 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast i8* [[B]] to i32* ; CHECK-NEXT: store i32 [[X22]], i32* [[TMP4]], align 4 -; CHECK-NEXT: store i32 [[X22]], i32* [[C_CAST]], align 4 +; CHECK-NEXT: [[TMP5:%.*]] = bitcast i8* [[C:%.*]] to i32* +; CHECK-NEXT: store i32 [[X22]], i32* [[TMP5]], align 4 ; CHECK-NEXT: ret void ; entry: Index: llvm/test/Transforms/InstCombine/logical-select.ll =================================================================== --- llvm/test/Transforms/InstCombine/logical-select.ll +++ llvm/test/Transforms/InstCombine/logical-select.ll @@ -549,8 +549,8 @@ define <4 x i8> @allSignBits_vec(<4 x i8> %cond, <4 x i8> %tval, <4 x i8> %fval) { ; CHECK-LABEL: @allSignBits_vec( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <4 x i8> [[COND:%.*]], -; CHECK-NEXT: [[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i8> [[FVAL:%.*]], <4 x i8> [[TVAL:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <4 x i8> [[COND:%.*]], zeroinitializer +; CHECK-NEXT: [[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i8> [[TVAL:%.*]], <4 x i8> [[FVAL:%.*]] ; CHECK-NEXT: ret <4 x i8> [[TMP2]] ; %bitmask = ashr <4 x i8> %cond, Index: llvm/test/Transforms/InstCombine/max-of-nots.ll =================================================================== --- llvm/test/Transforms/InstCombine/max-of-nots.ll +++ llvm/test/Transforms/InstCombine/max-of-nots.ll @@ -3,7 +3,7 @@ define <2 x i32> @umin_of_nots(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @umin_of_nots( -; CHECK-NEXT: [[TMP1:%.*]] = icmp ult <2 x i32> [[Y:%.*]], [[X:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt <2 x i32> [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[TMP2:%.*]] = select <2 x i1> [[TMP1]], <2 x i32> [[X]], <2 x i32> [[Y]] ; CHECK-NEXT: [[MIN:%.*]] = xor <2 x i32> [[TMP2]], ; CHECK-NEXT: ret <2 x i32> [[MIN]] @@ -17,7 +17,7 @@ define <2 x i32> @smin_of_nots(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @smin_of_nots( -; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <2 x i32> [[Y:%.*]], [[X:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <2 x i32> [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[TMP2:%.*]] = select <2 x i1> [[TMP1]], <2 x i32> [[X]], <2 x i32> [[Y]] ; CHECK-NEXT: [[MIN:%.*]] = xor <2 x i32> [[TMP2]], ; CHECK-NEXT: ret <2 x i32> [[MIN]] @@ -31,7 +31,7 @@ define i32 @compute_min_2(i32 %x, i32 %y) { ; CHECK-LABEL: @compute_min_2( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[Y:%.*]], [[X:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 [[X]], i32 [[Y]] ; CHECK-NEXT: ret i32 [[TMP2]] ; @@ -47,7 +47,7 @@ define i8 @umin_not_1_extra_use(i8 %x, i8 %y) { ; CHECK-LABEL: @umin_not_1_extra_use( ; CHECK-NEXT: [[NX:%.*]] = xor i8 [[X:%.*]], -1 -; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i8 [[X]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i8 [[Y:%.*]], [[X]] ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i8 [[Y]], i8 [[X]] ; CHECK-NEXT: [[MINXY:%.*]] = xor i8 [[TMP2]], -1 ; CHECK-NEXT: call void @extra_use(i8 [[NX]]) @@ -84,7 +84,7 @@ define i8 @umin3_not(i8 %x, i8 %y, i8 %z) { ; CHECK-LABEL: @umin3_not( -; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i8 [[Z:%.*]], [[X:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i8 [[X:%.*]], [[Z:%.*]] ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i8 [[X]], i8 [[Z]] ; CHECK-NEXT: [[TMP3:%.*]] = icmp ugt i8 [[TMP2]], [[Y:%.*]] ; CHECK-NEXT: [[R_V:%.*]] = select i1 [[TMP3]], i8 [[TMP2]], i8 [[Y]] @@ -109,7 +109,7 @@ ; CHECK-LABEL: @umin3_not_more_uses( ; CHECK-NEXT: [[NX:%.*]] = xor i8 [[X:%.*]], -1 ; CHECK-NEXT: [[NY:%.*]] = xor i8 [[Y:%.*]], -1 -; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i8 [[X]], [[Z:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i8 [[Z:%.*]], [[X]] ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i8 [[Z]], i8 [[X]] ; CHECK-NEXT: [[TMP3:%.*]] = icmp ugt i8 [[TMP2]], [[Y]] ; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TMP3]], i8 [[TMP2]], i8 [[Y]] @@ -163,7 +163,7 @@ define i32 @compute_min_3(i32 %x, i32 %y, i32 %z) { ; CHECK-LABEL: @compute_min_3( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[Y:%.*]], [[X:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 [[X]], i32 [[Y]] ; CHECK-NEXT: [[TMP3:%.*]] = icmp slt i32 [[TMP2]], [[Z:%.*]] ; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TMP3]], i32 [[TMP2]], i32 [[Z]] @@ -223,8 +223,8 @@ ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 [[Y]], i32 0 ; CHECK-NEXT: [[TMP3:%.*]] = icmp slt i32 [[TMP2]], [[X:%.*]] ; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TMP3]], i32 [[TMP2]], i32 [[X]] -; CHECK-NEXT: [[TMP5:%.*]] = xor i32 [[TMP4]], -1 -; CHECK-NEXT: ret i32 [[TMP5]] +; CHECK-NEXT: [[SMAX96:%.*]] = xor i32 [[TMP4]], -1 +; CHECK-NEXT: ret i32 [[SMAX96]] ; %c0 = icmp sgt i32 %y, 0 %xor_y = xor i32 %y, -1 @@ -264,8 +264,8 @@ ; CHECK-NEXT: [[TMP2:%.*]] = select <2 x i1> [[TMP1]], <2 x i32> [[Y]], <2 x i32> zeroinitializer ; CHECK-NEXT: [[TMP3:%.*]] = icmp slt <2 x i32> [[TMP2]], [[X:%.*]] ; CHECK-NEXT: [[TMP4:%.*]] = select <2 x i1> [[TMP3]], <2 x i32> [[TMP2]], <2 x i32> [[X]] -; CHECK-NEXT: [[TMP5:%.*]] = xor <2 x i32> [[TMP4]], -; CHECK-NEXT: ret <2 x i32> [[TMP5]] +; CHECK-NEXT: [[SMAX96:%.*]] = xor <2 x i32> [[TMP4]], +; CHECK-NEXT: ret <2 x i32> [[SMAX96]] ; %c0 = icmp sgt <2 x i32> %y, zeroinitializer %xor_y = xor <2 x i32> %y, @@ -282,8 +282,8 @@ ; CHECK-NEXT: [[TMP2:%.*]] = select <2 x i1> [[TMP1]], <2 x i37> [[Y]], <2 x i37> zeroinitializer ; CHECK-NEXT: [[TMP3:%.*]] = icmp slt <2 x i37> [[TMP2]], [[X:%.*]] ; CHECK-NEXT: [[TMP4:%.*]] = select <2 x i1> [[TMP3]], <2 x i37> [[TMP2]], <2 x i37> [[X]] -; CHECK-NEXT: [[TMP5:%.*]] = xor <2 x i37> [[TMP4]], -; CHECK-NEXT: ret <2 x i37> [[TMP5]] +; CHECK-NEXT: [[SMAX96:%.*]] = xor <2 x i37> [[TMP4]], +; CHECK-NEXT: ret <2 x i37> [[SMAX96]] ; %c0 = icmp sgt <2 x i37> %y, zeroinitializer %xor_y = xor <2 x i37> %y, Index: llvm/test/Transforms/InstCombine/or.ll =================================================================== --- llvm/test/Transforms/InstCombine/or.ll +++ llvm/test/Transforms/InstCombine/or.ll @@ -161,7 +161,7 @@ ; CHECK-LABEL: @test25( ; CHECK-NEXT: [[C:%.*]] = icmp ne i32 [[A:%.*]], 0 ; CHECK-NEXT: [[D:%.*]] = icmp ne i32 [[B:%.*]], 57 -; CHECK-NEXT: [[F:%.*]] = and i1 [[D]], [[C]] +; CHECK-NEXT: [[F:%.*]] = and i1 [[C]], [[D]] ; CHECK-NEXT: ret i1 [[F]] ; %C = icmp eq i32 %A, 0 @@ -333,8 +333,8 @@ define i1 @test33(i1 %X, i1 %Y) { ; CHECK-LABEL: @test33( -; CHECK-NEXT: [[B:%.*]] = or i1 [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: ret i1 [[B]] +; CHECK-NEXT: [[A:%.*]] = or i1 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret i1 [[A]] ; %a = or i1 %X, %Y %b = or i1 %a, %X @@ -343,8 +343,8 @@ define i32 @test34(i32 %X, i32 %Y) { ; CHECK-LABEL: @test34( -; CHECK-NEXT: [[B:%.*]] = or i32 [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: ret i32 [[B]] +; CHECK-NEXT: [[A:%.*]] = or i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret i32 [[A]] ; %a = or i32 %X, %Y %b = or i32 %Y, %a Index: llvm/test/Transforms/InstCombine/pr38915.ll =================================================================== --- llvm/test/Transforms/InstCombine/pr38915.ll +++ llvm/test/Transforms/InstCombine/pr38915.ll @@ -5,7 +5,7 @@ ; CHECK-LABEL: @PR38915( ; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[X:%.*]], -1 ; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[Y:%.*]], -1 -; CHECK-NEXT: [[TMP3:%.*]] = icmp sgt i32 [[TMP2]], [[TMP1]] +; CHECK-NEXT: [[TMP3:%.*]] = icmp slt i32 [[TMP1]], [[TMP2]] ; CHECK-NEXT: [[M1N:%.*]] = select i1 [[TMP3]], i32 [[TMP1]], i32 [[TMP2]] ; CHECK-NEXT: [[C2:%.*]] = icmp sgt i32 [[M1N]], [[Z:%.*]] ; CHECK-NEXT: [[M2:%.*]] = select i1 [[C2]], i32 [[M1N]], i32 [[Z]] Index: llvm/test/Transforms/InstCombine/pr44245.ll =================================================================== --- llvm/test/Transforms/InstCombine/pr44245.ll +++ llvm/test/Transforms/InstCombine/pr44245.ll @@ -157,12 +157,11 @@ ; CHECK: for.cond: ; CHECK-NEXT: br i1 [[C:%.*]], label [[COND_TRUE133:%.*]], label [[COND_FALSE138:%.*]] ; CHECK: cond.true133: -; CHECK-NEXT: store %type_3* undef, %type_3** null, align 536870912 ; CHECK-NEXT: br label [[COND_END144:%.*]] ; CHECK: cond.false138: -; CHECK-NEXT: store %type_3* undef, %type_3** null, align 536870912 ; CHECK-NEXT: br label [[COND_END144]] ; CHECK: cond.end144: +; CHECK-NEXT: store %type_3* undef, %type_3** null, align 536870912 ; CHECK-NEXT: br label [[WHILE_COND]] ; entry: Index: llvm/test/Transforms/InstCombine/select-cmp-br.ll =================================================================== --- llvm/test/Transforms/InstCombine/select-cmp-br.ll +++ llvm/test/Transforms/InstCombine/select-cmp-br.ll @@ -15,9 +15,9 @@ ; CHECK-NEXT: [[M:%.*]] = load i64*, i64** [[TMP]], align 8 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[C]], %C* [[ARG]], i64 1, i32 0, i32 0 ; CHECK-NEXT: [[N:%.*]] = load i64*, i64** [[TMP1]], align 8 -; CHECK-NEXT: [[NOT_TMP5:%.*]] = icmp ne i64* [[M]], [[N]] +; CHECK-NEXT: [[TMP5:%.*]] = icmp ne i64* [[M]], [[N]] ; CHECK-NEXT: [[TMP71:%.*]] = icmp eq %C* [[ARG]], null -; CHECK-NEXT: [[TMP7:%.*]] = or i1 [[TMP71]], [[NOT_TMP5]] +; CHECK-NEXT: [[TMP7:%.*]] = or i1 [[TMP5]], [[TMP71]] ; CHECK-NEXT: br i1 [[TMP7]], label [[BB10:%.*]], label [[BB8:%.*]] ; CHECK: bb: ; CHECK-NEXT: ret void @@ -115,9 +115,9 @@ ; CHECK-NEXT: [[M:%.*]] = load i64*, i64** [[TMP]], align 8 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[C]], %C* [[ARG]], i64 1, i32 0, i32 0 ; CHECK-NEXT: [[N:%.*]] = load i64*, i64** [[TMP1]], align 8 -; CHECK-NEXT: [[NOT_TMP5:%.*]] = icmp ne i64* [[M]], [[N]] +; CHECK-NEXT: [[TMP5:%.*]] = icmp ne i64* [[M]], [[N]] ; CHECK-NEXT: [[TMP71:%.*]] = icmp eq %C* [[ARG]], null -; CHECK-NEXT: [[TMP7:%.*]] = or i1 [[TMP71]], [[NOT_TMP5]] +; CHECK-NEXT: [[TMP7:%.*]] = or i1 [[TMP5]], [[TMP71]] ; CHECK-NEXT: br i1 [[TMP7]], label [[BB10:%.*]], label [[BB8:%.*]] ; CHECK: bb: ; CHECK-NEXT: ret void Index: llvm/test/Transforms/InstCombine/select-pr39595.ll =================================================================== --- llvm/test/Transforms/InstCombine/select-pr39595.ll +++ llvm/test/Transforms/InstCombine/select-pr39595.ll @@ -2,7 +2,7 @@ define i32 @foo(i32 %x, i32 %y) { ; CHECK-LABEL: foo -; CHECK: [[TMP1:%.*]] = icmp ult i32 %y, %x +; CHECK: [[TMP1:%.*]] = icmp ugt i32 %x, %y ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 %x, i32 %y, !prof ![[$MD0:[0-9]+]] ; CHECK-NEXT: [[TMP3:%.*]] = xor i32 [[TMP2]], -1 ; CHECK-NEXT: ret i32 [[TMP3:%.*]] Index: llvm/test/Transforms/InstCombine/sub-ashr-and-to-icmp-select.ll =================================================================== --- llvm/test/Transforms/InstCombine/sub-ashr-and-to-icmp-select.ll +++ llvm/test/Transforms/InstCombine/sub-ashr-and-to-icmp-select.ll @@ -12,7 +12,7 @@ define i8 @sub_ashr_and_i8(i8 %x, i8 %y) { ; CHECK-LABEL: @sub_ashr_and_i8( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i8 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[AND:%.*]] = select i1 [[TMP1]], i8 [[X]], i8 0 ; CHECK-NEXT: ret i8 [[AND]] ; @@ -24,7 +24,7 @@ define i16 @sub_ashr_and_i16(i16 %x, i16 %y) { ; CHECK-LABEL: @sub_ashr_and_i16( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i16 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i16 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[AND:%.*]] = select i1 [[TMP1]], i16 [[X]], i16 0 ; CHECK-NEXT: ret i16 [[AND]] ; @@ -37,7 +37,7 @@ define i32 @sub_ashr_and_i32(i32 %x, i32 %y) { ; CHECK-LABEL: @sub_ashr_and_i32( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[AND:%.*]] = select i1 [[TMP1]], i32 [[X]], i32 0 ; CHECK-NEXT: ret i32 [[AND]] ; @@ -49,7 +49,7 @@ define i64 @sub_ashr_and_i64(i64 %x, i64 %y) { ; CHECK-LABEL: @sub_ashr_and_i64( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i64 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i64 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[AND:%.*]] = select i1 [[TMP1]], i64 [[X]], i64 0 ; CHECK-NEXT: ret i64 [[AND]] ; @@ -63,7 +63,7 @@ define i32 @sub_ashr_and_i32_nuw_nsw(i32 %x, i32 %y) { ; CHECK-LABEL: @sub_ashr_and_i32_nuw_nsw( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[AND:%.*]] = select i1 [[TMP1]], i32 [[X]], i32 0 ; CHECK-NEXT: ret i32 [[AND]] ; @@ -77,7 +77,7 @@ define i32 @sub_ashr_and_i32_commute(i32 %x, i32 %y) { ; CHECK-LABEL: @sub_ashr_and_i32_commute( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[AND:%.*]] = select i1 [[TMP1]], i32 [[X]], i32 0 ; CHECK-NEXT: ret i32 [[AND]] ; @@ -91,7 +91,7 @@ define <4 x i32> @sub_ashr_and_i32_vec(<4 x i32> %x, <4 x i32> %y) { ; CHECK-LABEL: @sub_ashr_and_i32_vec( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <4 x i32> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <4 x i32> [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[AND:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> [[X]], <4 x i32> zeroinitializer ; CHECK-NEXT: ret <4 x i32> [[AND]] ; @@ -103,7 +103,7 @@ define <4 x i32> @sub_ashr_and_i32_vec_nuw_nsw(<4 x i32> %x, <4 x i32> %y) { ; CHECK-LABEL: @sub_ashr_and_i32_vec_nuw_nsw( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <4 x i32> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <4 x i32> [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[AND:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> [[X]], <4 x i32> zeroinitializer ; CHECK-NEXT: ret <4 x i32> [[AND]] ; @@ -115,7 +115,7 @@ define <4 x i32> @sub_ashr_and_i32_vec_commute(<4 x i32> %x, <4 x i32> %y) { ; CHECK-LABEL: @sub_ashr_and_i32_vec_commute( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <4 x i32> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <4 x i32> [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[AND:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> [[X]], <4 x i32> zeroinitializer ; CHECK-NEXT: ret <4 x i32> [[AND]] ; @@ -144,7 +144,7 @@ define i32 @sub_ashr_and_i32_extra_use_and(i32 %x, i32 %y, i32* %p) { ; CHECK-LABEL: @sub_ashr_and_i32_extra_use_and( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[AND:%.*]] = select i1 [[TMP1]], i32 [[X]], i32 0 ; CHECK-NEXT: store i32 [[AND]], i32* [[P:%.*]], align 4 ; CHECK-NEXT: ret i32 [[AND]] Index: llvm/test/Transforms/InstCombine/sub-ashr-or-to-icmp-select.ll =================================================================== --- llvm/test/Transforms/InstCombine/sub-ashr-or-to-icmp-select.ll +++ llvm/test/Transforms/InstCombine/sub-ashr-or-to-icmp-select.ll @@ -26,7 +26,7 @@ define i8 @sub_ashr_or_i8(i8 %x, i8 %y) { ; CHECK-LABEL: @sub_ashr_or_i8( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i8 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[OR:%.*]] = select i1 [[TMP1]], i8 -1, i8 [[X]] ; CHECK-NEXT: ret i8 [[OR]] ; @@ -38,7 +38,7 @@ define i16 @sub_ashr_or_i16(i16 %x, i16 %y) { ; CHECK-LABEL: @sub_ashr_or_i16( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i16 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i16 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[OR:%.*]] = select i1 [[TMP1]], i16 -1, i16 [[X]] ; CHECK-NEXT: ret i16 [[OR]] ; @@ -50,7 +50,7 @@ define i32 @sub_ashr_or_i32(i32 %x, i32 %y) { ; CHECK-LABEL: @sub_ashr_or_i32( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[OR:%.*]] = select i1 [[TMP1]], i32 -1, i32 [[X]] ; CHECK-NEXT: ret i32 [[OR]] ; @@ -62,7 +62,7 @@ define i64 @sub_ashr_or_i64(i64 %x, i64 %y) { ; CHECK-LABEL: @sub_ashr_or_i64( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i64 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i64 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[OR:%.*]] = select i1 [[TMP1]], i64 -1, i64 [[X]] ; CHECK-NEXT: ret i64 [[OR]] ; @@ -76,7 +76,7 @@ define i32 @sub_ashr_or_i32_nuw_nsw(i32 %x, i32 %y) { ; CHECK-LABEL: @sub_ashr_or_i32_nuw_nsw( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[OR:%.*]] = select i1 [[TMP1]], i32 -1, i32 [[X]] ; CHECK-NEXT: ret i32 [[OR]] ; @@ -90,7 +90,7 @@ define i32 @sub_ashr_or_i32_commute(i32 %x, i32 %y) { ; CHECK-LABEL: @sub_ashr_or_i32_commute( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[OR:%.*]] = select i1 [[TMP1]], i32 -1, i32 [[X]] ; CHECK-NEXT: ret i32 [[OR]] ; @@ -104,7 +104,7 @@ define <4 x i32> @sub_ashr_or_i32_vec(<4 x i32> %x, <4 x i32> %y) { ; CHECK-LABEL: @sub_ashr_or_i32_vec( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <4 x i32> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <4 x i32> [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[OR:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> , <4 x i32> [[X]] ; CHECK-NEXT: ret <4 x i32> [[OR]] ; @@ -116,7 +116,7 @@ define <4 x i32> @sub_ashr_or_i32_vec_nuw_nsw(<4 x i32> %x, <4 x i32> %y) { ; CHECK-LABEL: @sub_ashr_or_i32_vec_nuw_nsw( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <4 x i32> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <4 x i32> [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[OR:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> , <4 x i32> [[X]] ; CHECK-NEXT: ret <4 x i32> [[OR]] ; @@ -128,7 +128,7 @@ define <4 x i32> @sub_ashr_or_i32_vec_commute(<4 x i32> %x, <4 x i32> %y) { ; CHECK-LABEL: @sub_ashr_or_i32_vec_commute( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <4 x i32> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <4 x i32> [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[OR:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> , <4 x i32> [[X]] ; CHECK-NEXT: ret <4 x i32> [[OR]] ; @@ -157,7 +157,7 @@ define i32 @sub_ashr_or_i32_extra_use_or(i32 %x, i32 %y, i32* %p) { ; CHECK-LABEL: @sub_ashr_or_i32_extra_use_or( -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[OR:%.*]] = select i1 [[TMP1]], i32 -1, i32 [[X]] ; CHECK-NEXT: store i32 [[OR]], i32* [[P:%.*]], align 4 ; CHECK-NEXT: ret i32 [[OR]] Index: llvm/test/Transforms/InstCombine/sub-gep.ll =================================================================== --- llvm/test/Transforms/InstCombine/sub-gep.ll +++ llvm/test/Transforms/InstCombine/sub-gep.ll @@ -73,9 +73,9 @@ ; The sub and shl here could be nuw, but this is harder to handle. define i64 @test_inbounds_nuw_two_gep([0 x i32]* %base, i64 %idx, i64 %idx2) { ; CHECK-LABEL: @test_inbounds_nuw_two_gep( -; CHECK-NEXT: [[P2_IDX1:%.*]] = sub i64 [[IDX2:%.*]], [[IDX:%.*]] -; CHECK-NEXT: [[TMP1:%.*]] = shl i64 [[P2_IDX1]], 2 -; CHECK-NEXT: ret i64 [[TMP1]] +; CHECK-NEXT: [[TMP1:%.*]] = sub i64 [[IDX2:%.*]], [[IDX:%.*]] +; CHECK-NEXT: [[DIFF_NEG:%.*]] = shl i64 [[TMP1]], 2 +; CHECK-NEXT: ret i64 [[DIFF_NEG]] ; %p1 = getelementptr inbounds [0 x i32], [0 x i32]* %base, i64 0, i64 %idx %p2 = getelementptr inbounds [0 x i32], [0 x i32]* %base, i64 0, i64 %idx2 @@ -89,7 +89,7 @@ ; CHECK-LABEL: @test_inbounds_nuw_multi_index( ; CHECK-NEXT: [[P2_IDX:%.*]] = shl nsw i64 [[IDX:%.*]], 3 ; CHECK-NEXT: [[P2_IDX1:%.*]] = shl nsw i64 [[IDX2:%.*]], 2 -; CHECK-NEXT: [[P2_OFFS2:%.*]] = add i64 [[P2_IDX]], [[P2_IDX1]] +; CHECK-NEXT: [[P2_OFFS2:%.*]] = add i64 [[P2_IDX1]], [[P2_IDX]] ; CHECK-NEXT: ret i64 [[P2_OFFS2]] ; %p1 = getelementptr inbounds [0 x [2 x i32]], [0 x [2 x i32]]* %base, i64 0, i64 0, i64 0 Index: llvm/test/Transforms/InstCombine/sub-minmax.ll =================================================================== --- llvm/test/Transforms/InstCombine/sub-minmax.ll +++ llvm/test/Transforms/InstCombine/sub-minmax.ll @@ -147,7 +147,7 @@ define i32 @max_bi_na_minus_na_use(i32 %A, i32 %Bi) { ; CHECK-LABEL: @max_bi_na_minus_na_use( -; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 [[A:%.*]], [[BI:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i32 [[BI:%.*]], [[A:%.*]] ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 [[BI]], i32 [[A]] ; CHECK-NEXT: [[L1:%.*]] = xor i32 [[TMP2]], -1 ; CHECK-NEXT: [[X:%.*]] = sub i32 [[A]], [[TMP2]] @@ -165,7 +165,7 @@ define i32 @na_minus_max_bi_na_use(i32 %A, i32 %Bi) { ; CHECK-LABEL: @na_minus_max_bi_na_use( -; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 [[A:%.*]], [[BI:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i32 [[BI:%.*]], [[A:%.*]] ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 [[BI]], i32 [[A]] ; CHECK-NEXT: [[L1:%.*]] = xor i32 [[TMP2]], -1 ; CHECK-NEXT: [[X:%.*]] = sub i32 [[TMP2]], [[A]] @@ -223,7 +223,7 @@ define i32 @max_bi_na_minus_na_use2(i32 %A, i32 %Bi) { ; CHECK-LABEL: @max_bi_na_minus_na_use2( ; CHECK-NEXT: [[NOT:%.*]] = xor i32 [[A:%.*]], -1 -; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 [[A]], [[BI:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i32 [[BI:%.*]], [[A]] ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 [[BI]], i32 [[A]] ; CHECK-NEXT: [[L1:%.*]] = xor i32 [[TMP2]], -1 ; CHECK-NEXT: [[X:%.*]] = sub i32 [[A]], [[TMP2]] @@ -244,7 +244,7 @@ define i32 @na_minus_max_bi_na_use2(i32 %A, i32 %Bi) { ; CHECK-LABEL: @na_minus_max_bi_na_use2( ; CHECK-NEXT: [[NOT:%.*]] = xor i32 [[A:%.*]], -1 -; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 [[A]], [[BI:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i32 [[BI:%.*]], [[A]] ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 [[BI]], i32 [[A]] ; CHECK-NEXT: [[L1:%.*]] = xor i32 [[TMP2]], -1 ; CHECK-NEXT: [[X:%.*]] = sub i32 [[TMP2]], [[A]] @@ -264,7 +264,7 @@ define i8 @umin_not_sub(i8 %x, i8 %y) { ; CHECK-LABEL: @umin_not_sub( -; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i8 [[Y:%.*]], [[X:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i8 [[X]], i8 [[Y]] ; CHECK-NEXT: [[MINXY:%.*]] = xor i8 [[TMP2]], -1 ; CHECK-NEXT: [[SUBX:%.*]] = sub i8 [[TMP2]], [[X]] @@ -286,7 +286,7 @@ define i8 @umin_not_sub_rev(i8 %x, i8 %y) { ; CHECK-LABEL: @umin_not_sub_rev( -; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i8 [[Y:%.*]], [[X:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i8 [[X]], i8 [[Y]] ; CHECK-NEXT: [[MINXY:%.*]] = xor i8 [[TMP2]], -1 ; CHECK-NEXT: [[SUBX:%.*]] = sub i8 [[X]], [[TMP2]] Index: llvm/test/Transforms/InstCombine/vec_sext.ll =================================================================== --- llvm/test/Transforms/InstCombine/vec_sext.ll +++ llvm/test/Transforms/InstCombine/vec_sext.ll @@ -4,8 +4,8 @@ define <4 x i32> @vec_select(<4 x i32> %a, <4 x i32> %b) { ; CHECK-LABEL: @vec_select( ; CHECK-NEXT: [[SUB:%.*]] = sub nsw <4 x i32> zeroinitializer, [[A:%.*]] -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <4 x i32> [[B:%.*]], -; CHECK-NEXT: [[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> [[A]], <4 x i32> [[SUB]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <4 x i32> [[B:%.*]], zeroinitializer +; CHECK-NEXT: [[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> [[SUB]], <4 x i32> [[A]] ; CHECK-NEXT: ret <4 x i32> [[TMP2]] ; %cmp = icmp slt <4 x i32> %b, zeroinitializer @@ -23,8 +23,8 @@ define <4 x i32> @vec_select_alternate_sign_bit_test(<4 x i32> %a, <4 x i32> %b) { ; CHECK-LABEL: @vec_select_alternate_sign_bit_test( ; CHECK-NEXT: [[SUB:%.*]] = sub nsw <4 x i32> zeroinitializer, [[A:%.*]] -; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <4 x i32> [[B:%.*]], -; CHECK-NEXT: [[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> [[SUB]], <4 x i32> [[A]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <4 x i32> [[B:%.*]], zeroinitializer +; CHECK-NEXT: [[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> [[A]], <4 x i32> [[SUB]] ; CHECK-NEXT: ret <4 x i32> [[TMP2]] ; %cmp = icmp sgt <4 x i32> %b, Index: llvm/test/Transforms/InstCombine/xor.ll =================================================================== --- llvm/test/Transforms/InstCombine/xor.ll +++ llvm/test/Transforms/InstCombine/xor.ll @@ -664,8 +664,8 @@ define i32 @test39(i32 %x) { ; CHECK-LABEL: @test39( ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], 255 -; CHECK-NEXT: [[RES:%.*]] = select i1 [[TMP1]], i32 [[X]], i32 255 -; CHECK-NEXT: ret i32 [[RES]] +; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 [[X]], i32 255 +; CHECK-NEXT: ret i32 [[TMP2]] ; %1 = xor i32 %x, -1 %2 = icmp sgt i32 %1, -256 @@ -747,7 +747,7 @@ define i32 @test45(i32 %x, i32 %y) { ; CHECK-LABEL: @test45( -; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 [[Y]], i32 [[X]] ; CHECK-NEXT: ret i32 [[TMP2]] ; @@ -853,7 +853,7 @@ ; CHECK-LABEL: @test50( ; CHECK-NEXT: [[TMP1:%.*]] = sub i32 1, [[X:%.*]] ; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[Y:%.*]], 1 -; CHECK-NEXT: [[TMP3:%.*]] = icmp slt i32 [[TMP2]], [[TMP1]] +; CHECK-NEXT: [[TMP3:%.*]] = icmp sgt i32 [[TMP1]], [[TMP2]] ; CHECK-NEXT: [[E:%.*]] = select i1 [[TMP3]], i32 [[TMP1]], i32 [[TMP2]] ; CHECK-NEXT: ret i32 [[E]] ; @@ -869,7 +869,7 @@ ; CHECK-LABEL: @test50vec( ; CHECK-NEXT: [[TMP1:%.*]] = sub <2 x i32> , [[X:%.*]] ; CHECK-NEXT: [[TMP2:%.*]] = add <2 x i32> [[Y:%.*]], -; CHECK-NEXT: [[TMP3:%.*]] = icmp slt <2 x i32> [[TMP2]], [[TMP1]] +; CHECK-NEXT: [[TMP3:%.*]] = icmp sgt <2 x i32> [[TMP1]], [[TMP2]] ; CHECK-NEXT: [[E:%.*]] = select <2 x i1> [[TMP3]], <2 x i32> [[TMP1]], <2 x i32> [[TMP2]] ; CHECK-NEXT: ret <2 x i32> [[E]] ; @@ -885,7 +885,7 @@ ; CHECK-LABEL: @test51( ; CHECK-NEXT: [[TMP1:%.*]] = sub i32 -3, [[X:%.*]] ; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[Y:%.*]], -3 -; CHECK-NEXT: [[TMP3:%.*]] = icmp sgt i32 [[TMP2]], [[TMP1]] +; CHECK-NEXT: [[TMP3:%.*]] = icmp slt i32 [[TMP1]], [[TMP2]] ; CHECK-NEXT: [[E:%.*]] = select i1 [[TMP3]], i32 [[TMP1]], i32 [[TMP2]] ; CHECK-NEXT: ret i32 [[E]] ; @@ -901,7 +901,7 @@ ; CHECK-LABEL: @test51vec( ; CHECK-NEXT: [[TMP1:%.*]] = sub <2 x i32> , [[X:%.*]] ; CHECK-NEXT: [[TMP2:%.*]] = add <2 x i32> [[Y:%.*]], -; CHECK-NEXT: [[TMP3:%.*]] = icmp sgt <2 x i32> [[TMP2]], [[TMP1]] +; CHECK-NEXT: [[TMP3:%.*]] = icmp slt <2 x i32> [[TMP1]], [[TMP2]] ; CHECK-NEXT: [[E:%.*]] = select <2 x i1> [[TMP3]], <2 x i32> [[TMP1]], <2 x i32> [[TMP2]] ; CHECK-NEXT: ret <2 x i32> [[E]] ;