[llvm] [AMDGPU] Add OMOD folding for TRANS bfloat16 instructions (PR #208595)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 06:29:04 PDT 2026


================
@@ -2379,6 +2433,25 @@ bool SIFoldOperandsImpl::tryFoldOMod(MachineInstr &MI) {
     return false;
 
   MachineInstr *Def = MRI->getVRegDef(RegOp->getReg());
+
+  // Look through REG_SEQUENCE to find the actual instruction.
+  // For BF16 operations, the result is often packed via REG_SEQUENCE with
+  // lo16 subreg for the actual value.
+  if (Def->isRegSequence()) {
+    if (Def->getNumOperands() < 2 || !Def->getOperand(1).isReg())
+      return false;
+
+    Register SrcReg = Def->getOperand(1).getReg();
----------------
jayfoad wrote:

Does not seem safe to assume that the first operand is for lo16 without checking. I think the operands for REG_SEQUENCE could go in any order?

https://github.com/llvm/llvm-project/pull/208595


More information about the llvm-commits mailing list