[llvm] 50db987 - [InstSimplify] move extract with undef index fold; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 24 10:22:16 PDT 2021
Author: Sanjay Patel
Date: 2021-06-24T13:22:10-04:00
New Revision: 50db987d5936260a30a1df69e6abfcb4434692ec
URL: https://github.com/llvm/llvm-project/commit/50db987d5936260a30a1df69e6abfcb4434692ec
DIFF: https://github.com/llvm/llvm-project/commit/50db987d5936260a30a1df69e6abfcb4434692ec.diff
LOG: [InstSimplify] move extract with undef index fold; NFC
This puts it closer to the other undef query check and
will avoid a potential ordering problem if we allow
folding non-constant-int indexes.
Added:
Modified:
llvm/lib/Analysis/InstructionSimplify.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 62eeacc40fc8..2dbd3e0f7ad3 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4536,6 +4536,11 @@ static Value *SimplifyExtractElementInst(Value *Vec, Value *Idx,
return UndefValue::get(VecVTy->getElementType());
}
+ // An undef extract index can be arbitrarily chosen to be an out-of-range
+ // index value, which would result in the instruction being poison.
+ if (Q.isUndefValue(Idx))
+ return PoisonValue::get(VecVTy->getElementType());
+
// If extracting a specified index from the vector, see if we can recursively
// find a previously computed scalar that was inserted into the vector.
if (auto *IdxC = dyn_cast<ConstantInt>(Idx)) {
@@ -4550,12 +4555,6 @@ static Value *SimplifyExtractElementInst(Value *Vec, Value *Idx,
if (Value *Elt = findScalarElement(Vec, IdxC->getZExtValue()))
return Elt;
}
-
- // An undef extract index can be arbitrarily chosen to be an out-of-range
- // index value, which would result in the instruction being poison.
- if (Q.isUndefValue(Idx))
- return PoisonValue::get(VecVTy->getElementType());
-
return nullptr;
}
More information about the llvm-commits
mailing list