[llvm] [VPlan] Handle calls in VPInstruction:opcodeMayReadOrWriteFromMemory. (PR #190681)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 7 09:17:51 PDT 2026
================
@@ -1373,6 +1373,10 @@ bool VPInstruction::opcodeMayReadOrWriteFromMemory() const {
case VPInstruction::VScale:
case VPInstruction::Unpack:
return false;
+ case Instruction::Call:
+ return !cast<Function>(
+ cast<VPIRValue>(getOperand(getNumOperands() - 1))->getValue())
----------------
fhahn wrote:
> Perhaps a getLastOperand() helper function along with a comment here in the code explaining the Function is possibly the last argument?
I added a helper that returns the function + the operand index with an explanation of the cases handled, thanks!
> Furthermore, judging by the code in getNumOperandsForOpcode it seems like this unconditional cast might be unsafe and you actually need something like:
We should always have a function, but when masked, it may be the second-to-last operand. This is now handled correctly, although not sure if this currently can be exercised in the current path.
> Yeah it's a bit strange we have code here that's only used for the pre-widened VPInstructions. Can we instead just assert !(isa_and_nonnull<Instruction>(R->getUnderyingValue()) && R->getUnderlyingInstr()->mayReadFromMemory()) in areAllLoadsDereferenceable?
We could but there are other places that could be migrated to VPlan that would need accurate info about whether a VPInstruction call accesses memory or not. Those can be served via the generic interface.
https://github.com/llvm/llvm-project/pull/190681
More information about the llvm-commits
mailing list