================
@@ -3899,9 +3915,41 @@ bool SIInstrInfo::foldImmediate(MachineInstr &UseMI,
MachineInstr &DefMI,
return true;
}
+
+ return false;
}
- return false;
+ // Early exit for generic instructions which will never fold an immediate.
+ if (!isTargetSpecificOpcode(UseMI.getOpcode()))
+ return false;
+
+ // Directly fold inline immediates into the uses. These should be free-ish
+ // regardless of the uses.
+ bool FoldedInlineImm = false;
+
+ for (MachineOperand &UseMO : UseMI.explicit_uses()) {
+ if (!UseMO.isReg() || UseMO.getReg() != Reg)
+ continue;
+
+ unsigned UseOpIdx = UseMO.getOperandNo();
+
+ int64_t ImmVal = Imm;
+ if (unsigned UseSubReg = UseMO.getSubReg()) {
+ std::optional<int64_t> SubImm = extractSubregFromImm(Imm, UseSubReg);
+ if (!SubImm)
+ continue;
+ ImmVal = *SubImm;
+ }
+
+ if (!isInlineConstant(UseMI, UseOpIdx, ImmVal))
----------------
arsenm wrote:
This stuff really should come directly from the instruction definition
(consequently we should have a lot more instruction definitions, or some kind
of OperandKindByHwMode). Requiring littering
hasNoF16PseudoScalarTransInlineConstants checks everywhere you do anything with
a constant is a bad design.
isInlineConstant already has the context of the instruction, so if it's broken
it's a bug there.
https://github.com/llvm/llvm-project/pull/208423
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits