[llvm] AMDGPU/GlobalISel: Legalize BF16 for FP math opcodes (PR #214059)
Petar Avramovic via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 5 06:21:48 PDT 2026
================
@@ -976,36 +974,42 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_,
getActionDefinitionsBuilder(G_BLOCK_ADDR).legalFor({CodePtr});
auto &FPOpActions =
- getActionDefinitionsBuilder({G_FADD, G_FMUL, G_FMA, G_FCANONICALIZE,
- G_STRICT_FADD, G_STRICT_FMUL, G_STRICT_FMA})
+ getActionDefinitionsBuilder({G_FADD, G_FMUL, G_FMA, G_FCANONICALIZE})
+ .legalFor({F32, F64});
+ auto &StrictFPOpActions =
+ getActionDefinitionsBuilder({G_STRICT_FADD, G_STRICT_FMUL, G_STRICT_FMA})
.legalFor({F32, F64});
auto &TrigActions =
getActionDefinitionsBuilder({G_FSIN, G_FCOS}).customFor({F32, F64});
auto &FDIVActions = getActionDefinitionsBuilder(G_FDIV).customFor({F32, F64});
if (ST.has16BitInsts()) {
- if (ST.hasVOP3PInsts())
+ if (ST.hasVOP3PInsts()) {
FPOpActions.legalFor({F16, V2F16});
- else
+ StrictFPOpActions.legalFor({F16, V2F16});
+ } else {
FPOpActions.legalFor({F16});
+ StrictFPOpActions.legalFor({F16});
+ }
TrigActions.customFor({F16});
FDIVActions.customFor({F16});
}
+ FPOpActions.widenScalarFor({BF16}, changeElementTo(0, F32));
----------------
petar-avramovic wrote:
this should work for strict opcodes as well I assume
https://github.com/llvm/llvm-project/pull/214059
More information about the llvm-commits
mailing list