[llvm] AMDGPU: Don't pack a build_vector with an undef/poison lane (PR #211871)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 24 10:49:05 PDT 2026
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/211871
Once ISD::POISON is legal it reaches isel and is treated as canonical, so
is_canonicalized_2<build_vector> matched build_vector<x, poison> and selected
a v_pack for a don't-care high lane. Avoids regressions in future patches.
Co-authored-by: Claude (Claude-Opus-4.8)
>From 9ea470d0a16a1a3c83afffdf50d77fb868edfcc0 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Fri, 24 Jul 2026 19:27:58 +0200
Subject: [PATCH] AMDGPU: Don't pack a build_vector with an undef/poison lane
Once ISD::POISON is legal it reaches isel and is treated as canonical, so
is_canonicalized_2<build_vector> matched build_vector<x, poison> and selected
a v_pack for a don't-care high lane. Avoids regressions in future patches.
Co-authored-by: Claude (Claude-Opus-4.8)
---
llvm/lib/Target/AMDGPU/AMDGPUInstructions.td | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td b/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td
index 2387afe1cd362..31e1327de7991 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td
@@ -204,6 +204,13 @@ class is_canonicalized_2<SDPatternOperator op> : PatFrag<
const SITargetLowering &Lowering =
*static_cast<const SITargetLowering *>(getTargetLowering());
+ // A poison operand is trivially canonical, but packing it is
+ // pointless. Leave those to the cheaper build_vector-with-undef
+ // patterns rather than materializing a v_pack for a don't-care
+ // lane.
+ if (N->getOperand(0).isUndef() || N->getOperand(1).isUndef())
+ return false;
+
return Lowering.isCanonicalized(*CurDAG, N->getOperand(0)) &&
Lowering.isCanonicalized(*CurDAG, N->getOperand(1));
}]> {
More information about the llvm-commits
mailing list