[llvm] [VectorCombine] Avoid inserting freeze when scalarizing extend-extract if all extracts would lead to UB on poison. (PR #164683)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 2 08:02:19 PST 2025
================
@@ -2017,8 +2017,31 @@ bool VectorCombine::scalarizeExtExtract(Instruction &I) {
Value *ScalarV = Ext->getOperand(0);
if (!isGuaranteedNotToBePoison(ScalarV, &AC, dyn_cast<Instruction>(ScalarV),
- &DT))
- ScalarV = Builder.CreateFreeze(ScalarV);
+ &DT)) {
+ // Check wether all lanes are extracted, all extracts trigger UB on
+ // poison, and the last extract (and hence all previous ones)
+ // are guaranteed to execute if Ext executes.
+ // If so, we do not need to insert a freeze.
----------------
fhahn wrote:
```suggestion
// are guaranteed to execute if Ext executes. If so, we do not need to insert a freeze.
```
https://github.com/llvm/llvm-project/pull/164683
More information about the llvm-commits
mailing list