[llvm] [SelectionDAG] Deal with POISON for INSERT_VECTOR_ELT/INSERT_SUBVECTOR (part 1) (PR #143102)
Björn Pettersson via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 5 05:25:31 PDT 2025
bjope wrote:
> Similarly - should we be allowed to remove freezes from constant pool loads entirely (maybe with some handling for undef elts in the Constant)?
I think so, but not quite sure how to best detect that in a good way.
One idea I had was to check for `TLI->getTargetConstantFromLoad(cast<LoadSDNode>(Op))` in `isGuaranteedNotToBeUndefOrPoison` (or `canCreateUndefOrPoison`) to identify LOAD from constant pool. But I haven't seen any benefit of that (except maybe in one lit test). That target hook is also only implemented for two targets.
Another thinking is that other constant loads also could be seen as frozen (e.g. loading from fixed stack). If so, then something like this in `isGuaranteedNotToBeUndefOrPoison` might be used (if it can be guaranteed that the LOAD won't result in poison due to index oob or something):
```
case ISD::LOAD: {
if (const PseudoSourceValue *PSV = cast<LoadSDNode>(Op)->getMemOperand()->getPseudoValue())
if (PSV->isConstant(&MF->getFrameInfo()))
return true;
break;
}
```
That latter would depend on that the MachineMemOperands are setup to identify that we load from constant pool etc.
https://github.com/llvm/llvm-project/pull/143102
More information about the llvm-commits
mailing list