Skip to content

Commit ce1fea8

Browse files
[AArch64][AMDGPU][Mips][PowerPC] Set fcanonicalize to Legal for f32,f64
Since the default OperationAction for `ISD::FCANONICALIZE` is now `Expand`, these targets need to explicitly set it to `Legal` in their backends in order to preserve their functionality.
1 parent da8fb7c commit ce1fea8

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,12 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
767767
setOperationAction(Op, MVT::v8bf16, Expand);
768768
}
769769

770+
// Legalize fcanonicalize to circumvent default expansion
771+
setOperationAction(ISD::FCANONICALIZE, {MVT::f32, MVT::f64}, Legal);
772+
if (Subtarget->hasFullFP16()) {
773+
setOperationAction(ISD::FCANONICALIZE, MVT::f16, Legal);
774+
}
775+
770776
// fpextend from f16 or bf16 to f32 is legal
771777
setOperationAction(ISD::FP_EXTEND, MVT::f32, Legal);
772778
setOperationAction(ISD::FP_EXTEND, MVT::v4f32, Legal);

llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@ AMDGPUTargetLowering::AMDGPUTargetLowering(const TargetMachine &TM,
423423
setOperationAction({ISD::FLOG10, ISD::FLOG, ISD::FEXP, ISD::FEXP10}, MVT::f16,
424424
Custom);
425425

426+
setOperationAction(ISD::FCANONICALIZE, {MVT::f32, MVT::f64}, Legal);
427+
if (Subtarget->has16BitInsts()) {
428+
setOperationAction(ISD::FCANONICALIZE, MVT::f16, Legal);
429+
}
430+
426431
// FIXME: These IS_FPCLASS vector fp types are marked custom so it reaches
427432
// scalarization code. Can be removed when IS_FPCLASS expand isn't called by
428433
// default unless marked custom/legal.

llvm/lib/Target/Mips/MipsISelLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ MipsTargetLowering::MipsTargetLowering(const MipsTargetMachine &TM,
373373
setOperationAction(ISD::FMAXNUM, MVT::f64, Legal);
374374
setOperationAction(ISD::IS_FPCLASS, MVT::f32, Legal);
375375
setOperationAction(ISD::IS_FPCLASS, MVT::f64, Legal);
376+
setOperationAction(ISD::FCANONICALIZE, MVT::f32, Legal);
377+
setOperationAction(ISD::FCANONICALIZE, MVT::f64, Legal);
376378
} else {
377379
setOperationAction(ISD::FCANONICALIZE, MVT::f32, Custom);
378380
setOperationAction(ISD::FCANONICALIZE, MVT::f64, Custom);

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,8 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM,
777777
setOperationAction(ISD::FMAXNUM_IEEE, MVT::f32, Legal);
778778
setOperationAction(ISD::FMINNUM_IEEE, MVT::f64, Legal);
779779
setOperationAction(ISD::FMINNUM_IEEE, MVT::f32, Legal);
780+
setOperationAction(ISD::FCANONICALIZE, MVT::f64, Legal);
781+
setOperationAction(ISD::FCANONICALIZE, MVT::f32, Legal);
780782
}
781783

782784
if (Subtarget.hasAltivec()) {

0 commit comments

Comments
 (0)