[PATCH] D122489: [AMDGPU] Fix adding modifiers when creating v_cmpx instructions.

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 25 09:49:24 PDT 2022


foad added a comment.

Looks OK but needs a lit test.



================
Comment at: llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp:454
 
-  if (AMDGPU::getNamedOperandIdx(NewOpcode, AMDGPU::OpName::src0_modifiers) !=
-      -1)
-    Builder.addImm(0);
+  auto AddModifierOrZero = [&](unsigned OperandName) -> void {
+    if (AMDGPU::getNamedOperandIdx(NewOpcode, OperandName) != -1) {
----------------
I'd slightly prefer a "getNamedImmOperandOrZero" which just returns the immediate value, instead of calling Builder.add.


================
Comment at: llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp:456
+    if (AMDGPU::getNamedOperandIdx(NewOpcode, OperandName) != -1) {
+      if (auto *Mod = TII->getNamedOperand(VCmp, OperandName)) {
+        Builder.addImm(Mod->getImm());
----------------
Should probably reuse the index that you discarded on the line above, to avoid looking it up by name a second time.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122489/new/

https://reviews.llvm.org/D122489



More information about the llvm-commits mailing list