[llvm] [DAG] NFC: Reword SCALAR_TO_VECTOR poison comment in SimplifyDemandedBits (PR #226003)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 19:59:40 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-selectiondag

Author: Cyrus Ding (dingcyrus)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/226003.diff


1 Files Affected:

- (modified) llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp (+3-1) 


``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 7c97dfb2c806a..1b48a9bbce062 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: {

``````````

</details>


https://github.com/llvm/llvm-project/pull/226003


More information about the llvm-commits mailing list