[llvm] [DAG] NFC: Reword SCALAR_TO_VECTOR poison comment in SimplifyDemandedBits (PR #226003)
Cyrus Ding via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 23 19:59:01 PDT 2026
https://github.com/dingcyrus created https://github.com/llvm/llvm-project/pull/226003
Follow-up to #217185 (merged as d9d4b55c9157), addressing review feedback from @bjope on the comment wording in `TargetLowering::SimplifyDemandedBits`.
- Drops the ", not undef" phrasing, which read as a lattice claim and is incorrect under the poison-refines-undef reading; the intent was operational.
- States the operational rule and the reasoning: KnownUndef-driven folds substitute a chosen concrete value for undef bits (`zext(undef) -> 0` via `DemandedElts.isSubsetOf(KnownUndef)`, and the x86 shuffle `AND(0, undef) -> 0` combine), which is invalid for poison since consuming a poison lane yields poison.
No functional change.
>From efd72ff219a87ad2f830101ca198e9077ca3b364 Mon Sep 17 00:00:00 2001
From: Cyrus Ding <785101675 at qq.com>
Date: Thu, 24 Sep 2026 10:58:11 +0800
Subject: [PATCH] [DAG] NFC: Reword SCALAR_TO_VECTOR poison comment in
SimplifyDemandedBits
The previous wording ("poison, not undef") could be read as a lattice
claim, which is incorrect under the poison-refines-undef reading; the
intent was operational: the upper elements must not be treated as undef
by undef-keyed folds. Reword to state the operational rule and the reason:
KnownUndef-driven folds substitute a chosen concrete value for undef bits
(e.g. zext(undef) -> 0 via DemandedElts.isSubsetOf(KnownUndef), and the
x86 shuffle AND(0, undef) -> 0 combine), which is invalid for poison since
consuming a poison lane yields poison.
Addresses review feedback on #217185.
No functional change.
---
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 7c97dfb2c806a1..1b48a9bbce0628 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -3354,7 +3354,9 @@ bool TargetLowering::SimplifyDemandedVectorElts(
case ISD::SCALAR_TO_VECTOR: {
if (!DemandedElts[0])
return TLO.CombineTo(Op, TLO.DAG.getPOISON(VT));
- // Upper elements are poison, not undef - don't mark them as KnownUndef.
+ // Upper elements are poison; do not mark them as KnownUndef. Undef-driven
+ // folds that pick a concrete value for undef bits (e.g. zext(undef) -> 0,
+ // AND(0, undef) -> 0) are invalid for poison, which must propagate.
break;
}
case ISD::BITCAST: {
More information about the llvm-commits
mailing list