[PATCH] D122489: [AMDGPU] Fix adding modifiers when creating v_cmpx instructions.
Thomas Symalla via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 28 08:53:13 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3bd15c03c6d8: [AMDGPU] Fix adding modifiers when creating v_cmpx instructions. (authored by tsymalla).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122489/new/
https://reviews.llvm.org/D122489
Files:
llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp
llvm/test/CodeGen/AMDGPU/vcmp-saveexec-to-vcmpx.mir
Index: llvm/test/CodeGen/AMDGPU/vcmp-saveexec-to-vcmpx.mir
===================================================================
--- llvm/test/CodeGen/AMDGPU/vcmp-saveexec-to-vcmpx.mir
+++ llvm/test/CodeGen/AMDGPU/vcmp-saveexec-to-vcmpx.mir
@@ -1,5 +1,5 @@
-# RUN: llc -march=amdgcn -mcpu=gfx1010 -mattr=-wavefrontsize32,+wavefrontsize64 -run-pass=si-optimize-exec-masking -verify-machineinstrs %s -o - | FileCheck -check-prefix=GCN %s
-# RUN: llc -march=amdgcn -mcpu=gfx1030 -mattr=-wavefrontsize32,+wavefrontsize64 -run-pass=si-optimize-exec-masking -verify-machineinstrs %s -o - | FileCheck -check-prefix=GCN %s
+# RUN: llc -march=amdgcn -mcpu=gfx1010 -mattr=-wavefrontsize32,+wavefrontsize64 -run-pass=si-optimize-exec-masking -verify-machineinstrs %s -o - | FileCheck --check-prefixes=GCN,GFX1010 %s
+# RUN: llc -march=amdgcn -mcpu=gfx1030 -mattr=-wavefrontsize32,+wavefrontsize64 -run-pass=si-optimize-exec-masking -verify-machineinstrs %s -o - | FileCheck --check-prefixes=GCN,GFX1030 %s
---
@@ -22,3 +22,22 @@
$sgpr2_sgpr3 = COPY $exec, implicit-def $exec
$sgpr2_sgpr3 = S_AND_B64 killed renamable $sgpr2_sgpr3, killed renamable $sgpr0_sgpr1, implicit-def dead $scc
$exec = S_MOV_B64_term killed renamable $sgpr2_sgpr3
+...
+
+---
+# Check if the modifiers are preserved when generating the V_CMPX instruction.
+
+# GCN-LABEL: name: vcmp_saveexec_to_mov_vcmpx_check_abs
+# GFX1010: V_CMP_LT_F32_e64
+# GFX1010: S_AND_SAVEEXEC_B64
+# GFX1030: S_MOV_B64
+# GFX1030-NEXT: V_CMPX_LT_F32_nosdst_e64 0, 953267991, 2
+name: vcmp_saveexec_to_mov_vcmpx_check_abs
+tracksRegLiveness: true
+body: |
+ bb.0:
+ liveins: $vgpr0
+ renamable $sgpr0_sgpr1 = V_CMP_LT_F32_e64 0, 953267991, 2, $vgpr0, 0, implicit $mode, implicit $exec
+ $sgpr2_sgpr3 = COPY $exec, implicit-def $exec
+ $sgpr2_sgpr3 = S_AND_B64 killed renamable $sgpr2_sgpr3, killed renamable $sgpr0_sgpr1, implicit-def dead $scc
+ $exec = S_MOV_B64_term killed renamable $sgpr2_sgpr3
Index: llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp
+++ llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp
@@ -451,20 +451,19 @@
auto Builder = BuildMI(*VCmp.getParent(), std::next(InsertPosIt),
VCmp.getDebugLoc(), TII->get(NewOpcode));
- if (AMDGPU::getNamedOperandIdx(NewOpcode, AMDGPU::OpName::src0_modifiers) !=
- -1)
- Builder.addImm(0);
+ auto TryAddImmediateValueFromNamedOperand =
+ [&](unsigned OperandName) -> void {
+ if (auto *Mod = TII->getNamedOperand(VCmp, OperandName))
+ Builder.addImm(Mod->getImm());
+ };
+ TryAddImmediateValueFromNamedOperand(AMDGPU::OpName::src0_modifiers);
Builder.add(*Src0);
- if (AMDGPU::getNamedOperandIdx(NewOpcode, AMDGPU::OpName::src1_modifiers) !=
- -1)
- Builder.addImm(0);
-
+ TryAddImmediateValueFromNamedOperand(AMDGPU::OpName::src1_modifiers);
Builder.add(*Src1);
- if (AMDGPU::getNamedOperandIdx(NewOpcode, AMDGPU::OpName::clamp) != -1)
- Builder.addImm(0);
+ TryAddImmediateValueFromNamedOperand(AMDGPU::OpName::clamp);
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122489.418606.patch
Type: text/x-patch
Size: 3175 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220328/80d28fcb/attachment.bin>
More information about the llvm-commits
mailing list