[llvm] [DAG] canCreateUndefOrPoison/isGuaranteedNotToBeUndefOrPoison - SCALAR_TO_VECTOR upper elements are poison (PR #217185)

Cyrus Ding via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 19:52:15 PDT 2026


================
@@ -4906,16 +4906,17 @@ entry:
 define i32 @test_udot_v33i8_nomla(ptr nocapture readonly %a1) {
 ; CHECK-SD-LABEL: test_udot_v33i8_nomla:
 ; CHECK-SD:       // %bb.0: // %entry
-; CHECK-SD-NEXT:    ldr b1, [x0, #32]
+; CHECK-SD-NEXT:    ldrb w8, [x0, #32]
 ; CHECK-SD-NEXT:    ldp q3, q2, [x0]
 ; CHECK-SD-NEXT:    movi v0.2d, #0000000000000000
-; CHECK-SD-NEXT:    ushll v1.8h, v1.8b, #0
+; CHECK-SD-NEXT:    fmov s1, w8
----------------
dingcyrus wrote:

> You should probably update the SimplifyDemandedBits/SimplifyDemandedVectorElts cases as part of this patch as well.

  Done — thanks for the pointer. I've updated both SCALAR_TO_VECTOR cases in TargetLowering.cpp:

  - SimplifyDemandedBits: comment-only fix (undef → poison); the known-bits result was already correct since poison upper elements are just "unknown".
  - SimplifyDemandedVectorElts: dropped the KnownUndef.setHighBits(NumElts - 1) line, which was misreporting the poison upper elements as KnownUndef. That matters because ZERO_EXTEND / ZERO_EXTEND_VECTOR_INREG fold zext(undef) to zero via DemandedElts.isSubsetOf(KnownUndef), which is invalid for poison — poison propagates through zext instead of becoming zero.

  One observable codegen change from this: CodeGen/X86/bfloat.ll (PR92471, SSE2) now emits two extra pextrw/pinsrw instructions to explicitly zero the poison padding lane instead of folding it away. Semantically identical, just more conservative; I updated those CHECK lines. neon-dotreduce.ll and the rest of the AArch64/X86 CodeGen tests are unaffected.


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


More information about the llvm-commits mailing list