[llvm] [AMDGPU] Handle MachineOperandType global address in SIFoldOperands. (PR #135424)
Dhruva Chakrabarti via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 25 18:57:18 PDT 2025
================
@@ -1161,6 +1161,10 @@ void SIFoldOperandsImpl::foldOperand(
if (OpToFold.isImm())
UseMI->getOperand(1).ChangeToImmediate(OpToFold.getImm());
+ else if (OpToFold.isGlobal())
+ UseMI->getOperand(1).ChangeToGA(OpToFold.getGlobal(),
+ OpToFold.getOffset(),
+ OpToFold.getTargetFlags());
else
UseMI->getOperand(1).ChangeToFrameIndex(OpToFold.getIndex());
----------------
dhruvachak wrote:
> I can modify the patch to the first approach you mention here. Since we enter this block only in case `FoldingImmLike` is true and this variable is a bool for either immediate, frame index or global values. The if-else if-else conditions focus on only these 3 operands so there won't be any edge case for the else condition as we enter the block when it is one of the 3 operands.
>
> But I'm not clear on how/where should I move the setDesc() to, since it is almost at the top of the block and the if-else if-else is immediately after it.
>
> The structure is ->
>
> if(FoldingImmLike){ if(execMaybeModifiedBeforeUse) return; UseMI->setDesc() // at the top of the block, in case the exec flag immediately above is false if-else if-else block UseMI->removeOperand(2) return; }
>
> Where should I place setDesc() to avoid a side effect?
I think setDesc() has to be sunk only if you bail out. How about the following?
if (isImm()) {}
else if (isFI()) {}
else {
assert(isGlobal());
...
}
Then you don't need to move setDesc().
https://github.com/llvm/llvm-project/pull/135424
More information about the llvm-commits
mailing list