forked from OSchip/llvm-project
[InstSimplify] allow partial undef constants for vector min/max folds
This commit is contained in:
parent
3c20ede18b
commit
3e8534fbc6
|
@ -5266,16 +5266,15 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1,
|
|||
if (isa<Constant>(Op0))
|
||||
std::swap(Op0, Op1);
|
||||
|
||||
// TODO: Allow partial undef vector constants.
|
||||
const APInt *C;
|
||||
if (!match(Op1, m_APInt(C)))
|
||||
if (!match(Op1, m_APIntAllowUndef(C)))
|
||||
break;
|
||||
|
||||
if ((IID == Intrinsic::smax && C->isMaxSignedValue()) ||
|
||||
(IID == Intrinsic::smin && C->isMinSignedValue()) ||
|
||||
(IID == Intrinsic::umax && C->isMaxValue()) ||
|
||||
(IID == Intrinsic::umin && C->isMinValue()))
|
||||
return Op1;
|
||||
return ConstantInt::get(ReturnType, *C);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -218,8 +218,7 @@ define <2 x i8> @umin_maxval_commute(<2 x i8> %x) {
|
|||
|
||||
define <2 x i8> @smax_maxval_partial_undef(<2 x i8> %x) {
|
||||
; CHECK-LABEL: @smax_maxval_partial_undef(
|
||||
; CHECK-NEXT: [[R:%.*]] = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 undef, i8 127>, <2 x i8> [[X:%.*]])
|
||||
; CHECK-NEXT: ret <2 x i8> [[R]]
|
||||
; CHECK-NEXT: ret <2 x i8> <i8 127, i8 127>
|
||||
;
|
||||
%r = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 undef, i8 127>, <2 x i8> %x)
|
||||
ret <2 x i8> %r
|
||||
|
@ -227,8 +226,7 @@ define <2 x i8> @smax_maxval_partial_undef(<2 x i8> %x) {
|
|||
|
||||
define <2 x i8> @smin_minval_partial_undef(<2 x i8> %x) {
|
||||
; CHECK-LABEL: @smin_minval_partial_undef(
|
||||
; CHECK-NEXT: [[R:%.*]] = call <2 x i8> @llvm.smin.v2i8(<2 x i8> [[X:%.*]], <2 x i8> <i8 -128, i8 undef>)
|
||||
; CHECK-NEXT: ret <2 x i8> [[R]]
|
||||
; CHECK-NEXT: ret <2 x i8> <i8 -128, i8 -128>
|
||||
;
|
||||
%r = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> <i8 -128, i8 undef>)
|
||||
ret <2 x i8> %r
|
||||
|
@ -236,8 +234,7 @@ define <2 x i8> @smin_minval_partial_undef(<2 x i8> %x) {
|
|||
|
||||
define <2 x i8> @umax_maxval_partial_undef(<2 x i8> %x) {
|
||||
; CHECK-LABEL: @umax_maxval_partial_undef(
|
||||
; CHECK-NEXT: [[R:%.*]] = call <2 x i8> @llvm.umax.v2i8(<2 x i8> <i8 -1, i8 undef>, <2 x i8> [[X:%.*]])
|
||||
; CHECK-NEXT: ret <2 x i8> [[R]]
|
||||
; CHECK-NEXT: ret <2 x i8> <i8 -1, i8 -1>
|
||||
;
|
||||
%r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> <i8 255, i8 undef>, <2 x i8> %x)
|
||||
ret <2 x i8> %r
|
||||
|
@ -245,8 +242,7 @@ define <2 x i8> @umax_maxval_partial_undef(<2 x i8> %x) {
|
|||
|
||||
define <2 x i8> @umin_minval_partial_undef(<2 x i8> %x) {
|
||||
; CHECK-LABEL: @umin_minval_partial_undef(
|
||||
; CHECK-NEXT: [[R:%.*]] = call <2 x i8> @llvm.umin.v2i8(<2 x i8> [[X:%.*]], <2 x i8> <i8 undef, i8 0>)
|
||||
; CHECK-NEXT: ret <2 x i8> [[R]]
|
||||
; CHECK-NEXT: ret <2 x i8> zeroinitializer
|
||||
;
|
||||
%r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> <i8 undef, i8 0>)
|
||||
ret <2 x i8> %r
|
||||
|
|
Loading…
Reference in New Issue