[llvm] [AMDGPU] Fix opcode comparison logic for G_INTRINSIC (PR #156008)
Piotr Balcer via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 29 04:08:32 PDT 2025
https://github.com/pbalcer created https://github.com/llvm/llvm-project/pull/156008
The check `(Opc < TargetOpcode::GENERIC_OP_END)` incorrectly includes`TargetOpcode::G_INTRINSIC` (129), which is greater than `GENERIC_OP_END` (313), leading to logically dead code.
This patch reorders the conditionals to first check for `G_INTRINSIC`, ensuring correct handling of the `amdgcn_fdot2` intrinsic.
>From 328306057f21b6e852357342ff7cb3e835139122 Mon Sep 17 00:00:00 2001
From: Piotr Balcer <piotr.balcer at intel.com>
Date: Fri, 29 Aug 2025 11:54:49 +0000
Subject: [PATCH] [AMDGPU] Fix opcode comparison logic for G_INTRINSIC
The check `(Opc < TargetOpcode::GENERIC_OP_END)` incorrectly
includes`TargetOpcode::G_INTRINSIC` (129), which is greater than
`GENERIC_OP_END` (313), leading to logically dead code.
This patch reorders the conditionals to first check for `G_INTRINSIC`, ensuring
correct handling of the `amdgcn_fdot2` intrinsic.
---
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
index fac365d015d95..70be259327023 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
@@ -4718,14 +4718,14 @@ class SearchOptions {
const MachineInstr *MI = MRI.getVRegDef(Reg);
unsigned Opc = MI->getOpcode();
- if (Opc < TargetOpcode::GENERIC_OP_END) {
- // Keep same for generic op.
- HasNeg = true;
- } else if (Opc == TargetOpcode::G_INTRINSIC) {
+ if (Opc == TargetOpcode::G_INTRINSIC) {
Intrinsic::ID IntrinsicID = cast<GIntrinsic>(*MI).getIntrinsicID();
// Only float point intrinsic has neg & neg_hi bits.
if (IntrinsicID == Intrinsic::amdgcn_fdot2)
HasNeg = true;
+ } else if (Opc < TargetOpcode::GENERIC_OP_END) {
+ // Keep same for generic op.
+ HasNeg = true;
}
}
bool checkOptions(SrcStatus Stat) const {
More information about the llvm-commits
mailing list