Skip to content

Commit 5bb2713

Browse files
committed
Invoking the fmulCombine in both the AMDGPUPreLegalCombine and AMDGPUPostLegalCombiner.
1 parent 3f7b408 commit 5bb2713

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

llvm/lib/Target/AMDGPU/AMDGPUCombine.td

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ def sign_extension_in_reg : GICombineRule<
125125
(apply [{ applyCombineSignExtendInReg(*${sign_inreg}, ${matchinfo}); }])>;
126126

127127
// Do the following combines :
128-
// fmul x, select(y, A, B) -> ldexp (x, select i32 (y, a, b))
129-
// fmul x, select(y, -A, -B) -> ldexp ((fneg x), select i32 (y, a, b))
130-
def combine_fmul_with_select_to_ldexp : GICombineRule<
128+
// fmul x, select(y, A, B) -> fldexp (x, select i32 (y, a, b))
129+
// fmul x, select(y, -A, -B) -> fldexp ((fneg x), select i32 (y, a, b))
130+
def combine_fmul_with_select_to_fldexp : GICombineRule<
131131
(defs root:$root, build_fn_matchinfo:$matchinfo),
132132
(match (G_FMUL $dst, $x, $select):$root,
133133
(G_SELECT $select, $y, $A, $B):$sel,
134-
[{ return Helper.matchCombineFmulWithSelectToLdexp(*${root}, *${sel}, ${matchinfo}); }]),
135-
(apply [{ Helper.applyBuildFn(*${root}, ${matchinfo}); }])>;
134+
[{ return Helper.matchCombineFmulWithSelectToFldexp(*${root}, *${sel}, ${matchinfo}); }]),
135+
(apply [{ Helper.applyBuildFn(*${root}, ${matchinfo}); }])>;
136136

137137

138138
let Predicates = [Has16BitInsts, NotHasMed3_16] in {
@@ -163,13 +163,13 @@ def gfx8_combines : GICombineGroup<[expand_promoted_fmed3]>;
163163

164164
def AMDGPUPreLegalizerCombiner: GICombiner<
165165
"AMDGPUPreLegalizerCombinerImpl",
166-
[all_combines, clamp_i64_to_i16, foldable_fneg]> {
166+
[all_combines, combine_fmul_with_select_to_fldexp, clamp_i64_to_i16, foldable_fneg]> {
167167
let CombineAllMethodName = "tryCombineAllImpl";
168168
}
169169

170170
def AMDGPUPostLegalizerCombiner: GICombiner<
171171
"AMDGPUPostLegalizerCombinerImpl",
172-
[all_combines, gfx6gfx7_combines, gfx8_combines,
172+
[all_combines, gfx6gfx7_combines, gfx8_combines, combine_fmul_with_select_to_fldexp,
173173
uchar_to_float, cvt_f32_ubyteN, remove_fcanonicalize, foldable_fneg,
174174
rcp_sqrt_to_rsq, fdiv_by_sqrt_to_rsq_f16, sign_extension_in_reg, smulu64]> {
175175
let CombineAllMethodName = "tryCombineAllImpl";

llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ void AMDGPUCombinerHelper::applyExpandPromotedF16FMed3(MachineInstr &MI,
446446
MI.eraseFromParent();
447447
}
448448

449-
bool AMDGPUCombinerHelper::matchCombineFmulWithSelectToLdexp(
449+
bool AMDGPUCombinerHelper::matchCombineFmulWithSelectToFldexp(
450450
MachineInstr &MI, MachineInstr &Sel,
451451
std::function<void(MachineIRBuilder &)> &MatchInfo) {
452452
assert(MI.getOpcode() == TargetOpcode::G_FMUL);
@@ -465,13 +465,13 @@ bool AMDGPUCombinerHelper::matchCombineFmulWithSelectToLdexp(
465465

466466
const auto SelectTrueCst =
467467
DestTy.isVector()
468-
? getFConstantSplat(SelectTrue, MRI, /* allowUndef */ true)
468+
? getFConstantSplat(SelectTrue, MRI, /*allowUndef=*/false)
469469
: getFConstantVRegValWithLookThrough(SelectTrue, MRI);
470470
if (!SelectTrueCst)
471471
return false;
472472
const auto SelectFalseCst =
473473
DestTy.isVector()
474-
? getFConstantSplat(SelectFalse, MRI, /* allowUndef */ true)
474+
? getFConstantSplat(SelectFalse, MRI, /*allowUndef=*/false)
475475
: getFConstantVRegValWithLookThrough(SelectFalse, MRI);
476476
if (!SelectFalseCst)
477477
return false;

llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AMDGPUCombinerHelper : public CombinerHelper {
3131
void applyExpandPromotedF16FMed3(MachineInstr &MI, Register Src0,
3232
Register Src1, Register Src2);
3333

34-
bool matchCombineFmulWithSelectToLdexp(
34+
bool matchCombineFmulWithSelectToFldexp(
3535
MachineInstr &MI, MachineInstr &Sel,
3636
std::function<void(MachineIRBuilder &)> &MatchInfo);
3737
};

0 commit comments

Comments
 (0)