diff options
author | Simon Moll <simon.moll@emea.nec.com> | 2022-05-30 12:19:48 +0200 |
---|---|---|
committer | Simon Moll <moll@cs.uni-saarland.de> | 2022-05-30 12:20:05 +0200 |
commit | 78a18d2b54e7e8e0e2c1d1cb33d015d7f69b8cc7 (patch) | |
tree | d68a9fa1d1664b7d469b52d66e63c44ad0a3ee79 /llvm/lib/CodeGen/ExpandVectorPredication.cpp | |
parent | 180d3f251d1ad5473705d3f00e6d426b5f8162e6 (diff) | |
download | llvm-78a18d2b54e7e8e0e2c1d1cb33d015d7f69b8cc7.zip llvm-78a18d2b54e7e8e0e2c1d1cb33d015d7f69b8cc7.tar.gz llvm-78a18d2b54e7e8e0e2c1d1cb33d015d7f69b8cc7.tar.bz2 |
[VP] vp intrinsics are not speculatable
VP intrinsics show UB if the %evl parameter is out of bounds - they must
not carry the speculatable attribute. The out-of-bounds UB disappears
when the %evl parameter is expanded into the mask or expansion replaces
the entire VP intrinsic with non-VP code.
This patch
- Removes the speculatable attribute on all VP intrinsics.
- Generalizes the isSafeToSpeculativelyExecute function to let VP
expansion know whether the VP intrinsic replacement will be
speculatable. VP expansion may only discard %evl where this is the
case.
Reviewed By: frasercrmck
Differential Revision: https://reviews.llvm.org/D125296
Diffstat (limited to 'llvm/lib/CodeGen/ExpandVectorPredication.cpp')
-rw-r--r-- | llvm/lib/CodeGen/ExpandVectorPredication.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/ExpandVectorPredication.cpp b/llvm/lib/CodeGen/ExpandVectorPredication.cpp index aa52914..fbb89a7 100644 --- a/llvm/lib/CodeGen/ExpandVectorPredication.cpp +++ b/llvm/lib/CodeGen/ExpandVectorPredication.cpp @@ -118,10 +118,10 @@ static bool maySpeculateLanes(VPIntrinsic &VPI) { if (isa<VPReductionIntrinsic>(VPI)) return false; // Fallback to whether the intrinsic is speculatable. - // FIXME: Check whether the replacing non-VP code will be speculatable - // instead. VP intrinsics themselves are never speculatable because of - // UB if %evl is greater than the runtime vector length. - return isSafeToSpeculativelyExecute(cast<Operator>(&VPI)); + Optional<unsigned> OpcOpt = VPI.getFunctionalOpcode(); + unsigned FunctionalOpc = OpcOpt.getValueOr((unsigned)Instruction::Call); + return isSafeToSpeculativelyExecuteWithOpcode(FunctionalOpc, + cast<Operator>(&VPI)); } //// } Helpers @@ -481,7 +481,7 @@ struct TransformJob { }; void sanitizeStrategy(VPIntrinsic &VPI, VPLegalization &LegalizeStrat) { - // Speculatable instructions do not strictly need predication. + // Operations with speculatable lanes do not strictly need predication. if (maySpeculateLanes(VPI)) { // Converting a speculatable VP intrinsic means dropping %mask and %evl. // No need to expand %evl into the %mask only to ignore that code. |