[llvm] Introducing a new ISD::POISON SDNode to represent the poison value in the IR. (PR #125883)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 3 12:50:08 PDT 2025


================
@@ -5,9 +5,10 @@ define dso_local void @foo() #1 {
 ; CHECK-LABEL: foo:
 ; CHECK:       # %bb.0: # %newFuncRoot
 ; CHECK-NEXT:    vpmovzxbd {{.*#+}} ymm0 = mem[0],zero,zero,zero,mem[1],zero,zero,zero,mem[2],zero,zero,zero,mem[3],zero,zero,zero,mem[4],zero,zero,zero,mem[5],zero,zero,zero,mem[6],zero,zero,zero,mem[7],zero,zero,zero
-; CHECK-NEXT:    vpbroadcastd {{.*#+}} ymm1 = [64,64,64,64,64,64,64,64]
-; CHECK-NEXT:    vpdpwssd {{\.?LCPI[0-9]+_[0-9]+}}(%rip){1to8}, %ymm0, %ymm1
-; CHECK-NEXT:    vpsrld $7, %ymm1, %ymm0
+; CHECK-NEXT:    vpbroadcastd {{.*#+}} ymm1 = [18,0,18,0,18,0,18,0,18,0,18,0,18,0,18,0]
+; CHECK-NEXT:    vpmaddwd        %ymm1, %ymm0, %ymm0
+; CHECK-NEXT:    vpaddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip){1to8}, %ymm0, %ymm0
----------------
topperc wrote:

Ok I looked at the log. It happens here

```
Combining: t5: v16i32 = zero_extend t4                                           
Creating new node: t50: v8i32,ch = load<(load (s64) from `ptr poison`, align 1), zext from v8i8> t0, poison:i64, undef:i64
Creating new node: t51: v8i32,ch = load<(load (s64) from `ptr poison` + 8, align 1), zext from v8i8> t0, undef:i64, undef:i64
Creating new node: t52: ch = TokenFactor t50:1, t51:1                            
Creating new node: t53: v16i32 = concat_vectors t50, t51
```

The load gets split and we need to increment the pointer by the size of the first split. This done as `add poison, 8` which is being folded to undef.

The fix would be to fold it to poison instead. Which we can do in a follow up.

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


More information about the llvm-commits mailing list