[llvm] [SelectionDAG] Return poison instead of undef for out-of-bounds EXTRACT_VECTOR_ELT (PR #192844)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 19 04:32:51 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: Xinlong Chen (Xinlong-Chen)
<details>
<summary>Changes</summary>
Out-of-bounds EXTRACT_VECTOR_ELT on fixed-length vectors is undefined behavior.
Return poison instead of undef to be consistent with LangRef semantics.
Prep work to help with https://github.com/llvm/llvm-project/pull/190307
---
Full diff: https://github.com/llvm/llvm-project/pull/192844.diff
1 Files Affected:
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (+2-2)
``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 86245e4044925..6c8d7742a80e4 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -8379,12 +8379,12 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
if (N1.isUndef() || N2.isUndef())
return getUNDEF(VT);
- // EXTRACT_VECTOR_ELT of out-of-bounds element is an UNDEF for fixed length
+ // EXTRACT_VECTOR_ELT of out-of-bounds element is an POISON for fixed length
// vectors. For scalable vectors we will provide appropriate support for
// dealing with arbitrary indices.
if (N2C && N1.getValueType().isFixedLengthVector() &&
N2C->getAPIntValue().uge(N1.getValueType().getVectorNumElements()))
- return getUNDEF(VT);
+ return getPOISON(VT);
// EXTRACT_VECTOR_ELT of CONCAT_VECTORS is often formed while lowering is
// expanding copies of large vectors from registers. This only works for
``````````
</details>
https://github.com/llvm/llvm-project/pull/192844
More information about the llvm-commits
mailing list