[PATCH] D106079: [AMDGPU] Divergence-driven compare operations instruction selection

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 16 06:23:26 PDT 2021


foad added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/SIInstrInfo.td:530
   (setcc node:$lhs, node:$rhs, node:$cond), [{
-  for (SDNode *Use : N->uses()) {
-    if (Use->isMachineOpcode() || Use->getOpcode() != ISD::CopyToReg)
-      return false;
-
-    unsigned Reg = cast<RegisterSDNode>(Use->getOperand(1))->getReg();
-    if (Reg != AMDGPU::SCC)
-      return false;
-  }
-  return true;
+  return !N->isDivergent();
 }]>;
----------------
I think you probably need to look ahead to see if this setcc is used by a divergent select. Otherwise you regress: `a == b ? c : d` where a and b are uniform but c or d are divergent. In this case it is better to use v_cmp than s_cmp, even though the operands are uniform, because it can feed straight into v_cndmask.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106079



More information about the llvm-commits mailing list