[PATCH] D143754: [MachineInstr] Introduce generic predicated copy opcode

Christudasan Devadasan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 16 10:05:48 PST 2023


cdevadas added a comment.

The IsPredicable field will always be turned to 1 for Pred_Copy to indicate that it is the Predicated version of the copy.

I actually wanted to have the Pred_Copy without these implicit operands. We should be able to model the dependency using an additional operand.
But I don't know how to model this operand and hence decided to continue using the implicit operand itself.

May be an immediate operand that takes const values (0, 1, 2, etc.)? 
The immediate values can be mapped to enumerations defined via target files to represent these predicated dependencies.
When there is no dependency, use the value 0. It means, there is no dependency and can change to the regular COPY.
If required, the Pred_Copy with Imm_opnd value 0 can also be modeled for the "predicate is false" scenario.

For example. the following can be defined for AMDGPU target in llvm/lib/Target/AMDGPU/SIDefines.h

enum Copy_Predication {

  None = 0,    // No dependency. It is for SGPR copies. At some point, convert the instruction into regular COPY.
  Lane_Copy,  // copy only the active lanes of VGPRs.
  Wave_Copy // copy all lanes of VGPRs

}

Any thoughts?



================
Comment at: llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp:204
   case TargetOpcode::COPY:
+  case TargetOpcode::PRED_COPY:
   case TargetOpcode::G_PHI:
----------------
bjope wrote:
> Here we have a typical example where I think it gets complicated to say that PRED_COPY is predicable. If the predicate is false, then you can't guarantee anything about the known bits. OTOH, if the predicate is guaranteed to be true, then there is no need to have a PRED_COPY.
The PRED_COPY here was added (like many other instances) for the codegen transformations to work as similar to the COPY opcode. Is there a need to consider the Predicable field here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143754



More information about the llvm-commits mailing list