[llvm] [DirectX] Change placeholders from `undef` to `poison` (PR #130970)
Pedro Lobo via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 12 08:12:20 PDT 2025
https://github.com/pedroclobo updated https://github.com/llvm/llvm-project/pull/130970
>From 428386a920933f6cc880c0d7f0b475552998e13c Mon Sep 17 00:00:00 2001
From: Pedro Lobo <pedro.lobo at tecnico.ulisboa.pt>
Date: Tue, 11 Mar 2025 22:54:55 +0000
Subject: [PATCH] [DirectX] Change placeholders from `undef` to `poison`
Call `insertelement` with a `poison` vector.
---
llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp | 2 +-
llvm/lib/Target/DirectX/DXILOpLowering.cpp | 2 +-
llvm/test/CodeGen/DirectX/BufferLoad.ll | 2 +-
llvm/test/CodeGen/DirectX/RawBufferLoad.ll | 14 +++++++-------
llvm/test/CodeGen/DirectX/cross.ll | 4 ++--
5 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp b/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
index cf142806bb1df..e44d3b70eb657 100644
--- a/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
+++ b/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
@@ -147,7 +147,7 @@ static Value *expandCrossIntrinsic(CallInst *Orig) {
Value *zx_xz = MulSub(op0_z, op0_x, op1_z, op1_x);
Value *xy_yx = MulSub(op0_x, op0_y, op1_x, op1_y);
- Value *cross = UndefValue::get(VT);
+ Value *cross = PoisonValue::get(VT);
cross = Builder.CreateInsertElement(cross, yz_zy, (uint64_t)0);
cross = Builder.CreateInsertElement(cross, zx_xz, 1);
cross = Builder.CreateInsertElement(cross, xy_yx, 2);
diff --git a/llvm/lib/Target/DirectX/DXILOpLowering.cpp b/llvm/lib/Target/DirectX/DXILOpLowering.cpp
index 63aeade9c19e4..203a24038f618 100644
--- a/llvm/lib/Target/DirectX/DXILOpLowering.cpp
+++ b/llvm/lib/Target/DirectX/DXILOpLowering.cpp
@@ -483,7 +483,7 @@ class OpLowerer {
if (!Extracts[I])
Extracts[I] = IRB.CreateExtractValue(Op, I);
- Value *Vec = UndefValue::get(OldTy);
+ Value *Vec = PoisonValue::get(OldTy);
for (int I = 0, E = N; I != E; ++I)
Vec = IRB.CreateInsertElement(Vec, Extracts[I], I);
OldResult->replaceAllUsesWith(Vec);
diff --git a/llvm/test/CodeGen/DirectX/BufferLoad.ll b/llvm/test/CodeGen/DirectX/BufferLoad.ll
index 3619f0aa63c5b..6d5146a9026ce 100644
--- a/llvm/test/CodeGen/DirectX/BufferLoad.ll
+++ b/llvm/test/CodeGen/DirectX/BufferLoad.ll
@@ -43,7 +43,7 @@ define void @loadv4f32() {
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATA4]], 1
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATA4]], 2
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATA4]], 3
- ; CHECK: insertelement <4 x float> undef
+ ; CHECK: insertelement <4 x float> poison
; CHECK: insertelement <4 x float>
; CHECK: insertelement <4 x float>
; CHECK: insertelement <4 x float>
diff --git a/llvm/test/CodeGen/DirectX/RawBufferLoad.ll b/llvm/test/CodeGen/DirectX/RawBufferLoad.ll
index 586b9c44e95d2..a79392433de5d 100644
--- a/llvm/test/CodeGen/DirectX/RawBufferLoad.ll
+++ b/llvm/test/CodeGen/DirectX/RawBufferLoad.ll
@@ -69,7 +69,7 @@ define void @loadv4f32_struct(i32 %index) {
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATA]], 1
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATA]], 2
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATA]], 3
- ; CHECK: insertelement <4 x float> undef
+ ; CHECK: insertelement <4 x float> poison
; CHECK: insertelement <4 x float>
; CHECK: insertelement <4 x float>
; CHECK: insertelement <4 x float>
@@ -97,7 +97,7 @@ define void @loadv4f32_byte(i32 %offset) {
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATA]], 1
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATA]], 2
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATA]], 3
- ; CHECK: insertelement <4 x float> undef
+ ; CHECK: insertelement <4 x float> poison
; CHECK: insertelement <4 x float>
; CHECK: insertelement <4 x float>
; CHECK: insertelement <4 x float>
@@ -125,7 +125,7 @@ define void @loadelements(i32 %index) {
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATAF32]], 1
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATAF32]], 2
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATAF32]], 3
- ; CHECK: insertelement <4 x float> undef
+ ; CHECK: insertelement <4 x float> poison
; CHECK: insertelement <4 x float>
; CHECK: insertelement <4 x float>
; CHECK: insertelement <4 x float>
@@ -144,7 +144,7 @@ define void @loadelements(i32 %index) {
; CHECK: extractvalue %dx.types.ResRet.i32 [[DATAI32]], 1
; CHECK: extractvalue %dx.types.ResRet.i32 [[DATAI32]], 2
; CHECK: extractvalue %dx.types.ResRet.i32 [[DATAI32]], 3
- ; CHECK: insertelement <4 x i32> undef
+ ; CHECK: insertelement <4 x i32> poison
; CHECK: insertelement <4 x i32>
; CHECK: insertelement <4 x i32>
; CHECK: insertelement <4 x i32>
@@ -180,7 +180,7 @@ define void @loadnested(i32 %index) {
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATAF32]], 1
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATAF32]], 2
; CHECK: extractvalue %dx.types.ResRet.f32 [[DATAF32]], 3
- ; CHECK: insertelement <4 x float> undef
+ ; CHECK: insertelement <4 x float> poison
; CHECK: insertelement <4 x float>
; CHECK: insertelement <4 x float>
; CHECK: insertelement <4 x float>
@@ -196,7 +196,7 @@ define void @loadnested(i32 %index) {
; CHECK: extractvalue %dx.types.ResRet.f16 [[DATAF16]], 0
; CHECK: extractvalue %dx.types.ResRet.f16 [[DATAF16]], 1
; CHECK: extractvalue %dx.types.ResRet.f16 [[DATAF16]], 2
- ; CHECK: insertelement <3 x half> undef
+ ; CHECK: insertelement <3 x half> poison
; CHECK: insertelement <3 x half>
; CHECK: insertelement <3 x half>
; CHECK: call void @v3f16_user(<3 x half>
@@ -221,7 +221,7 @@ define void @loadv4f64_byte(i32 %offset) {
; CHECK: extractvalue %dx.types.ResRet.f64 [[DATA]], 1
; CHECK: extractvalue %dx.types.ResRet.f64 [[DATA]], 2
; CHECK: extractvalue %dx.types.ResRet.f64 [[DATA]], 3
- ; CHECK: insertelement <4 x double> undef
+ ; CHECK: insertelement <4 x double> poison
; CHECK: insertelement <4 x double>
; CHECK: insertelement <4 x double>
; CHECK: insertelement <4 x double>
diff --git a/llvm/test/CodeGen/DirectX/cross.ll b/llvm/test/CodeGen/DirectX/cross.ll
index 6ec3ec4d3594a..e787c5035925b 100644
--- a/llvm/test/CodeGen/DirectX/cross.ll
+++ b/llvm/test/CodeGen/DirectX/cross.ll
@@ -22,7 +22,7 @@ entry:
; CHECK: %4 = fmul half %x0, %y1
; CHECK: %5 = fmul half %x1, %y0
; CHECK: %hlsl.cross3 = fsub half %4, %5
- ; CHECK: %6 = insertelement <3 x half> undef, half %hlsl.cross1, i64 0
+ ; CHECK: %6 = insertelement <3 x half> poison, half %hlsl.cross1, i64 0
; CHECK: %7 = insertelement <3 x half> %6, half %hlsl.cross2, i64 1
; CHECK: %8 = insertelement <3 x half> %7, half %hlsl.cross3, i64 2
; CHECK: ret <3 x half> %8
@@ -47,7 +47,7 @@ entry:
; CHECK: %4 = fmul float %x0, %y1
; CHECK: %5 = fmul float %x1, %y0
; CHECK: %hlsl.cross3 = fsub float %4, %5
- ; CHECK: %6 = insertelement <3 x float> undef, float %hlsl.cross1, i64 0
+ ; CHECK: %6 = insertelement <3 x float> poison, float %hlsl.cross1, i64 0
; CHECK: %7 = insertelement <3 x float> %6, float %hlsl.cross2, i64 1
; CHECK: %8 = insertelement <3 x float> %7, float %hlsl.cross3, i64 2
; CHECK: ret <3 x float> %8
More information about the llvm-commits
mailing list