[llvm] [AMDGPU][GlobalISel] Improve combining on v_ldexp (PR #190236)
Petar Avramovic via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 28 05:06:10 PDT 2026
================
@@ -518,6 +522,23 @@ bool AMDGPUCombinerHelper::matchCombineFmulWithSelectToFldexp(
return true;
}
+bool AMDGPUCombinerHelper::matchCombineFmulWithSelectToFldexp(
+ MachineInstr &MI, MachineInstr &Sel,
+ std::function<void(MachineIRBuilder &)> &MatchInfo) const {
+ Register Dst = MI.getOperand(0).getReg();
+ LLT ScalarDestTy = MRI.getType(Dst).getScalarType();
+
+ // fldexp has no SALU form. On targets with SALU float, defer this combine
+ // to the RegBankCombiner where register banks are known and we can limit it
+ // to VGPR (divergent) values only.
+ if (STI.hasSALUFloatInsts() &&
+ (ScalarDestTy == LLT::scalar(64) || ScalarDestTy == LLT::scalar(32) ||
+ ScalarDestTy == LLT::scalar(16)))
+ return false;
----------------
petar-avramovic wrote:
ok, great.
for tests, try adding gfx12 checks in test/CodeGen/AMDGPU/fmul-to-ldexp.ll
you will need to stop s16 and s32 mul -> v_ldexp combine in prelegalizer and do them in regbankcombiner instead (should see s_mul_f16 and s_mul_f32 in fmul-to-ldexp.ll instead of v_ldexp).
for now it is fine to leave s64 mul -> v_ldexp combine as is (there is no s_mul_f64)
https://github.com/llvm/llvm-project/pull/190236
More information about the llvm-commits
mailing list