aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/ExpandVectorPredication.cpp
diff options
context:
space:
mode:
authorliqin.weng <liqin.weng@spacemit.com>2023-09-12 09:44:49 +0800
committerliqin.weng <liqin.weng@spacemit.com>2023-09-12 10:15:52 +0800
commit1eec3574943f185c6a21b9ee9ee3213b503f9a74 (patch)
tree5b60087eb53c1e314c5ad7789f6a4f398c40b7df /llvm/lib/CodeGen/ExpandVectorPredication.cpp
parent2bdf5aa5dffffebf6e3b1afe588db990ca58e55c (diff)
downloadllvm-1eec3574943f185c6a21b9ee9ee3213b503f9a74.zip
llvm-1eec3574943f185c6a21b9ee9ee3213b503f9a74.tar.gz
llvm-1eec3574943f185c6a21b9ee9ee3213b503f9a74.tar.bz2
[VP] IR expansion for maxnum/minnum
Add basic handling for VP ops that can expand to non-predicate ops Reviewed By: RKSimon Differential Revision: https://reviews.llvm.org/D159494
Diffstat (limited to 'llvm/lib/CodeGen/ExpandVectorPredication.cpp')
-rw-r--r--llvm/lib/CodeGen/ExpandVectorPredication.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/ExpandVectorPredication.cpp b/llvm/lib/CodeGen/ExpandVectorPredication.cpp
index bf2291b..50182ce 100644
--- a/llvm/lib/CodeGen/ExpandVectorPredication.cpp
+++ b/llvm/lib/CodeGen/ExpandVectorPredication.cpp
@@ -318,6 +318,16 @@ Value *CachingVPExpander::expandPredicationToFPCall(
replaceOperation(*NewOp, VPI);
return NewOp;
}
+ case Intrinsic::maxnum:
+ case Intrinsic::minnum: {
+ Value *Op0 = VPI.getOperand(0);
+ Value *Op1 = VPI.getOperand(1);
+ Function *Fn = Intrinsic::getDeclaration(
+ VPI.getModule(), UnpredicatedIntrinsicID, {VPI.getType()});
+ Value *NewOp = Builder.CreateCall(Fn, {Op0, Op1}, VPI.getName());
+ replaceOperation(*NewOp, VPI);
+ return NewOp;
+ }
case Intrinsic::experimental_constrained_fma:
case Intrinsic::experimental_constrained_fmuladd: {
Value *Op0 = VPI.getOperand(0);
@@ -708,6 +718,10 @@ Value *CachingVPExpander::expandPredication(VPIntrinsic &VPI) {
return expandPredicationToFPCall(Builder, VPI, Intrinsic::fabs);
case Intrinsic::vp_sqrt:
return expandPredicationToFPCall(Builder, VPI, Intrinsic::sqrt);
+ case Intrinsic::vp_maxnum:
+ return expandPredicationToFPCall(Builder, VPI, Intrinsic::maxnum);
+ case Intrinsic::vp_minnum:
+ return expandPredicationToFPCall(Builder, VPI, Intrinsic::minnum);
case Intrinsic::vp_load:
case Intrinsic::vp_store:
case Intrinsic::vp_gather: