[llvm] [ExpandVectorPredication] Be more precise reporting changes (PR #102313)

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 8 00:33:28 PDT 2024


================
@@ -357,14 +357,12 @@ bool PreISelIntrinsicLowering::lowerIntrinsics(Module &M) const {
 #define BEGIN_REGISTER_VP_INTRINSIC(VPID, MASKPOS, VLENPOS)                    \
   case Intrinsic::VPID:
 #include "llvm/IR/VPIntrinsics.def"
-      forEachCall(F, [&](CallInst *CI) {
+      Changed |= forEachCall(F, [&](CallInst *CI) {
         Function *Parent = CI->getParent()->getParent();
         const TargetTransformInfo &TTI = LookupTTI(*Parent);
         auto *VPI = cast<VPIntrinsic>(CI);
         return expandVectorPredicationIntrinsic(*VPI, TTI);
----------------
aengelke wrote:

forEachCall iterates over the use list of the intrinsic and therefore requires to know whether the intrinsic call (`CI`) was removed. If it is removed, it CI is no longer in the use list and forEachCall dereferences the next use of the previous use, if it is not removed, forEachCall dereferences the next use of the intrinsic call.

Right now, expandVectorPredication will be called twice when it changes the code but does not remove the intrinsic call: the first time, forEachCall will not advance in the use list and call eVP a second time on the same CallInst, which will return false as the intrinsic is legal then.

https://github.com/llvm/llvm-project/pull/102313


More information about the llvm-commits mailing list