diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index c257cf9e1d03..2bfd11a2574d 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -1457,6 +1457,16 @@ Instruction *InstCombiner::foldSPFofSPF(Instruction *Inner, } } + // max(max(A, B), min(A, B)) --> max(A, B) + // min(min(A, B), max(A, B)) --> min(A, B) + // TODO: This could be done in instsimplify. + if (SPF1 == SPF2 && + ((SPF1 == SPF_UMIN && match(C, m_c_UMax(m_Specific(A), m_Specific(B)))) || + (SPF1 == SPF_SMIN && match(C, m_c_SMax(m_Specific(A), m_Specific(B)))) || + (SPF1 == SPF_UMAX && match(C, m_c_UMin(m_Specific(A), m_Specific(B)))) || + (SPF1 == SPF_SMAX && match(C, m_c_SMin(m_Specific(A), m_Specific(B)))))) + return replaceInstUsesWith(Outer, Inner); + // ABS(ABS(X)) -> ABS(X) // NABS(NABS(X)) -> NABS(X) // TODO: This could be done in instsimplify. diff --git a/llvm/test/Transforms/InstCombine/minmax-of-minmax.ll b/llvm/test/Transforms/InstCombine/minmax-of-minmax.ll index 06a361f6bae5..58f2099e4367 100644 --- a/llvm/test/Transforms/InstCombine/minmax-of-minmax.ll +++ b/llvm/test/Transforms/InstCombine/minmax-of-minmax.ll @@ -3,13 +3,9 @@ define i32 @smax_of_smax_smin_commute0(i32 %x, i32 %y) { ; CHECK-LABEL: @smax_of_smax_smin_commute0( -; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP1]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[Y]], [[X]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP2]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp sgt i32 [[MAX]], [[MIN]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], i32 [[MAX]], i32 [[MIN]] -; CHECK-NEXT: ret i32 [[R]] +; CHECK-NEXT: ret i32 [[MAX]] ; %cmp1 = icmp slt i32 %x, %y %min = select i1 %cmp1, i32 %x, i32 %y @@ -22,13 +18,9 @@ define i32 @smax_of_smax_smin_commute0(i32 %x, i32 %y) { define i32 @smax_of_smax_smin_commute1(i32 %x, i32 %y) { ; CHECK-LABEL: @smax_of_smax_smin_commute1( -; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP1]], i32 [[Y]], i32 [[X]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i32 [[X]], [[Y]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP2]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp sgt i32 [[MAX]], [[MIN]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], i32 [[MAX]], i32 [[MIN]] -; CHECK-NEXT: ret i32 [[R]] +; CHECK-NEXT: ret i32 [[MAX]] ; %cmp1 = icmp sgt i32 %x, %y %min = select i1 %cmp1, i32 %y, i32 %x @@ -41,13 +33,9 @@ define i32 @smax_of_smax_smin_commute1(i32 %x, i32 %y) { define i32 @smax_of_smax_smin_commute2(i32 %x, i32 %y) { ; CHECK-LABEL: @smax_of_smax_smin_commute2( -; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP1]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[Y]], [[X]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP2]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp slt i32 [[MIN]], [[MAX]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], i32 [[MAX]], i32 [[MIN]] -; CHECK-NEXT: ret i32 [[R]] +; CHECK-NEXT: ret i32 [[MAX]] ; %cmp1 = icmp slt i32 %x, %y %min = select i1 %cmp1, i32 %x, i32 %y @@ -60,13 +48,9 @@ define i32 @smax_of_smax_smin_commute2(i32 %x, i32 %y) { define <2 x i32> @smax_of_smax_smin_commute3(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @smax_of_smax_smin_commute3( -; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt <2 x i32> [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MIN:%.*]] = select <2 x i1> [[CMP1]], <2 x i32> [[Y]], <2 x i32> [[X]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt <2 x i32> [[X]], [[Y]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt <2 x i32> [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[MAX:%.*]] = select <2 x i1> [[CMP2]], <2 x i32> [[X]], <2 x i32> [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp slt <2 x i32> [[MIN]], [[MAX]] -; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[CMP3]], <2 x i32> [[MAX]], <2 x i32> [[MIN]] -; CHECK-NEXT: ret <2 x i32> [[R]] +; CHECK-NEXT: ret <2 x i32> [[MAX]] ; %cmp1 = icmp sgt <2 x i32> %x, %y %min = select <2 x i1> %cmp1, <2 x i32> %y, <2 x i32> %x @@ -79,13 +63,9 @@ define <2 x i32> @smax_of_smax_smin_commute3(<2 x i32> %x, <2 x i32> %y) { define i32 @smin_of_smin_smax_commute0(i32 %x, i32 %y) { ; CHECK-LABEL: @smin_of_smin_smax_commute0( -; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP1]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i32 [[Y]], [[X]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP2]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp sgt i32 [[MAX]], [[MIN]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], i32 [[MIN]], i32 [[MAX]] -; CHECK-NEXT: ret i32 [[R]] +; CHECK-NEXT: ret i32 [[MIN]] ; %cmp1 = icmp sgt i32 %x, %y %max = select i1 %cmp1, i32 %x, i32 %y @@ -98,13 +78,9 @@ define i32 @smin_of_smin_smax_commute0(i32 %x, i32 %y) { define i32 @smin_of_smin_smax_commute1(i32 %x, i32 %y) { ; CHECK-LABEL: @smin_of_smin_smax_commute1( -; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP1]], i32 [[Y]], i32 [[X]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[X]], [[Y]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP2]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp sgt i32 [[MAX]], [[MIN]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], i32 [[MIN]], i32 [[MAX]] -; CHECK-NEXT: ret i32 [[R]] +; CHECK-NEXT: ret i32 [[MIN]] ; %cmp1 = icmp slt i32 %x, %y %max = select i1 %cmp1, i32 %y, i32 %x @@ -117,13 +93,9 @@ define i32 @smin_of_smin_smax_commute1(i32 %x, i32 %y) { define <2 x i32> @smin_of_smin_smax_commute2(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @smin_of_smin_smax_commute2( -; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt <2 x i32> [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MAX:%.*]] = select <2 x i1> [[CMP1]], <2 x i32> [[X]], <2 x i32> [[Y]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp slt <2 x i32> [[X]], [[Y]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp slt <2 x i32> [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[MIN:%.*]] = select <2 x i1> [[CMP2]], <2 x i32> [[X]], <2 x i32> [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp slt <2 x i32> [[MIN]], [[MAX]] -; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[CMP3]], <2 x i32> [[MIN]], <2 x i32> [[MAX]] -; CHECK-NEXT: ret <2 x i32> [[R]] +; CHECK-NEXT: ret <2 x i32> [[MIN]] ; %cmp1 = icmp sgt <2 x i32> %x, %y %max = select <2 x i1> %cmp1, <2 x i32> %x, <2 x i32> %y @@ -136,13 +108,9 @@ define <2 x i32> @smin_of_smin_smax_commute2(<2 x i32> %x, <2 x i32> %y) { define i32 @smin_of_smin_smax_commute3(i32 %x, i32 %y) { ; CHECK-LABEL: @smin_of_smin_smax_commute3( -; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP1]], i32 [[Y]], i32 [[X]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i32 [[Y]], [[X]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP2]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp slt i32 [[MIN]], [[MAX]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], i32 [[MIN]], i32 [[MAX]] -; CHECK-NEXT: ret i32 [[R]] +; CHECK-NEXT: ret i32 [[MIN]] ; %cmp1 = icmp slt i32 %x, %y %max = select i1 %cmp1, i32 %y, i32 %x @@ -155,13 +123,9 @@ define i32 @smin_of_smin_smax_commute3(i32 %x, i32 %y) { define i32 @umax_of_umax_umin_commute0(i32 %x, i32 %y) { ; CHECK-LABEL: @umax_of_umax_umin_commute0( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP1]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i32 [[Y]], [[X]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP2]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp ugt i32 [[MAX]], [[MIN]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], i32 [[MAX]], i32 [[MIN]] -; CHECK-NEXT: ret i32 [[R]] +; CHECK-NEXT: ret i32 [[MAX]] ; %cmp1 = icmp ult i32 %x, %y %min = select i1 %cmp1, i32 %x, i32 %y @@ -174,13 +138,9 @@ define i32 @umax_of_umax_umin_commute0(i32 %x, i32 %y) { define i32 @umax_of_umax_umin_commute1(i32 %x, i32 %y) { ; CHECK-LABEL: @umax_of_umax_umin_commute1( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP1]], i32 [[Y]], i32 [[X]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i32 [[X]], [[Y]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i32 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP2]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp ugt i32 [[MAX]], [[MIN]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], i32 [[MAX]], i32 [[MIN]] -; CHECK-NEXT: ret i32 [[R]] +; CHECK-NEXT: ret i32 [[MAX]] ; %cmp1 = icmp ugt i32 %x, %y %min = select i1 %cmp1, i32 %y, i32 %x @@ -193,13 +153,9 @@ define i32 @umax_of_umax_umin_commute1(i32 %x, i32 %y) { define i32 @umax_of_umax_umin_commute2(i32 %x, i32 %y) { ; CHECK-LABEL: @umax_of_umax_umin_commute2( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP1]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i32 [[Y]], [[X]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP2]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp ult i32 [[MIN]], [[MAX]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], i32 [[MAX]], i32 [[MIN]] -; CHECK-NEXT: ret i32 [[R]] +; CHECK-NEXT: ret i32 [[MAX]] ; %cmp1 = icmp ult i32 %x, %y %min = select i1 %cmp1, i32 %x, i32 %y @@ -212,13 +168,9 @@ define i32 @umax_of_umax_umin_commute2(i32 %x, i32 %y) { define <2 x i32> @umax_of_umax_umin_commute3(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @umax_of_umax_umin_commute3( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt <2 x i32> [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MIN:%.*]] = select <2 x i1> [[CMP1]], <2 x i32> [[Y]], <2 x i32> [[X]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt <2 x i32> [[X]], [[Y]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt <2 x i32> [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[MAX:%.*]] = select <2 x i1> [[CMP2]], <2 x i32> [[X]], <2 x i32> [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp ult <2 x i32> [[MIN]], [[MAX]] -; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[CMP3]], <2 x i32> [[MAX]], <2 x i32> [[MIN]] -; CHECK-NEXT: ret <2 x i32> [[R]] +; CHECK-NEXT: ret <2 x i32> [[MAX]] ; %cmp1 = icmp ugt <2 x i32> %x, %y %min = select <2 x i1> %cmp1, <2 x i32> %y, <2 x i32> %x @@ -231,13 +183,9 @@ define <2 x i32> @umax_of_umax_umin_commute3(<2 x i32> %x, <2 x i32> %y) { define i32 @umin_of_umin_umax_commute0(i32 %x, i32 %y) { ; CHECK-LABEL: @umin_of_umin_umax_commute0( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP1]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i32 [[Y]], [[X]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP2]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp ugt i32 [[MAX]], [[MIN]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], i32 [[MIN]], i32 [[MAX]] -; CHECK-NEXT: ret i32 [[R]] +; CHECK-NEXT: ret i32 [[MIN]] ; %cmp1 = icmp ugt i32 %x, %y %max = select i1 %cmp1, i32 %x, i32 %y @@ -250,13 +198,9 @@ define i32 @umin_of_umin_umax_commute0(i32 %x, i32 %y) { define i32 @umin_of_umin_umax_commute1(i32 %x, i32 %y) { ; CHECK-LABEL: @umin_of_umin_umax_commute1( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP1]], i32 [[Y]], i32 [[X]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i32 [[X]], [[Y]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i32 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP2]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp ugt i32 [[MAX]], [[MIN]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], i32 [[MIN]], i32 [[MAX]] -; CHECK-NEXT: ret i32 [[R]] +; CHECK-NEXT: ret i32 [[MIN]] ; %cmp1 = icmp ult i32 %x, %y %max = select i1 %cmp1, i32 %y, i32 %x @@ -269,13 +213,9 @@ define i32 @umin_of_umin_umax_commute1(i32 %x, i32 %y) { define <2 x i32> @umin_of_umin_umax_commute2(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @umin_of_umin_umax_commute2( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt <2 x i32> [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MAX:%.*]] = select <2 x i1> [[CMP1]], <2 x i32> [[X]], <2 x i32> [[Y]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp ult <2 x i32> [[X]], [[Y]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp ult <2 x i32> [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[MIN:%.*]] = select <2 x i1> [[CMP2]], <2 x i32> [[X]], <2 x i32> [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp ult <2 x i32> [[MIN]], [[MAX]] -; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[CMP3]], <2 x i32> [[MIN]], <2 x i32> [[MAX]] -; CHECK-NEXT: ret <2 x i32> [[R]] +; CHECK-NEXT: ret <2 x i32> [[MIN]] ; %cmp1 = icmp ugt <2 x i32> %x, %y %max = select <2 x i1> %cmp1, <2 x i32> %x, <2 x i32> %y @@ -288,13 +228,9 @@ define <2 x i32> @umin_of_umin_umax_commute2(<2 x i32> %x, <2 x i32> %y) { define i32 @umin_of_umin_umax_commute3(i32 %x, i32 %y) { ; CHECK-LABEL: @umin_of_umin_umax_commute3( -; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[X:%.*]], [[Y:%.*]] -; CHECK-NEXT: [[MAX:%.*]] = select i1 [[CMP1]], i32 [[Y]], i32 [[X]] -; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i32 [[Y]], [[X]] +; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i32 [[Y:%.*]], [[X:%.*]] ; CHECK-NEXT: [[MIN:%.*]] = select i1 [[CMP2]], i32 [[X]], i32 [[Y]] -; CHECK-NEXT: [[CMP3:%.*]] = icmp ult i32 [[MIN]], [[MAX]] -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], i32 [[MIN]], i32 [[MAX]] -; CHECK-NEXT: ret i32 [[R]] +; CHECK-NEXT: ret i32 [[MIN]] ; %cmp1 = icmp ult i32 %x, %y %max = select i1 %cmp1, i32 %y, i32 %x @@ -305,6 +241,8 @@ define i32 @umin_of_umin_umax_commute3(i32 %x, i32 %y) { ret i32 %r } +; Negative test - mismatch of min/max flavor + define i32 @umin_of_smin_umax_wrong_pattern(i32 %x, i32 %y) { ; CHECK-LABEL: @umin_of_smin_umax_wrong_pattern( ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[X:%.*]], [[Y:%.*]] @@ -324,6 +262,8 @@ define i32 @umin_of_smin_umax_wrong_pattern(i32 %x, i32 %y) { ret i32 %r } +; Negative test - mismatch of min/max flavor + define i32 @smin_of_umin_umax_wrong_pattern2(i32 %x, i32 %y) { ; CHECK-LABEL: @smin_of_umin_umax_wrong_pattern2( ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[X:%.*]], [[Y:%.*]] @@ -343,6 +283,8 @@ define i32 @smin_of_umin_umax_wrong_pattern2(i32 %x, i32 %y) { ret i32 %r } +; Negative test - operands must match + define <2 x i32> @umin_of_umin_umax_wrong_operand(<2 x i32> %x, <2 x i32> %y, <2 x i32> %z) { ; CHECK-LABEL: @umin_of_umin_umax_wrong_operand( ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt <2 x i32> [[X:%.*]], [[Y:%.*]] @@ -362,6 +304,8 @@ define <2 x i32> @umin_of_umin_umax_wrong_operand(<2 x i32> %x, <2 x i32> %y, <2 ret <2 x i32> %r } +; Negative test - operands must match + define i32 @umin_of_umin_umax_wrong_operand2(i32 %x, i32 %y, i32 %z) { ; CHECK-LABEL: @umin_of_umin_umax_wrong_operand2( ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[X:%.*]], [[Z:%.*]]