Skip to content

Commit 696ea67

Browse files
committed
Disable call to fma for soft-float
PowerPC backend generate calls to libc function calls for soft-float, regardless of the -nostdlib /-ffreestanding flag. fma is not a function provided by compiler-rt builtins and thus should not be generated here. PR : [[ #55230 | #55230 ]] Below is patch given by @nemanjai Reviewed By: jhibbits Differential Revision: https://reviews.llvm.org/D156344
1 parent 3cbadc5 commit 696ea67

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17297,7 +17297,7 @@ bool PPCTargetLowering::isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
1729717297

1729817298
bool PPCTargetLowering::isFMAFasterThanFMulAndFAdd(const Function &F,
1729917299
Type *Ty) const {
17300-
if (Subtarget.hasSPE())
17300+
if (Subtarget.hasSPE() || Subtarget.useSoftFloat())
1730117301
return false;
1730217302
switch (Ty->getScalarType()->getTypeID()) {
1730317303
case Type::FloatTyID:

llvm/test/CodeGen/PowerPC/ppcsoftops.ll

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,25 @@ entry:
5151
; CHECK-LABEL: __divdf3
5252
}
5353

54+
; Function Attrs: noinline nounwind optnone uwtable
55+
define dso_local zeroext i32 @func(double noundef %0, double noundef %1) #0 {
56+
%3 = alloca double, align 8
57+
%4 = alloca double, align 8
58+
store double %0, ptr %3, align 8
59+
store double %1, ptr %4, align 8
60+
%5 = load double, ptr %3, align 8
61+
%6 = load double, ptr %4, align 8
62+
%7 = fneg double %6
63+
%8 = call double @llvm.fmuladd.f64(double %7, double 0x41F0000000000000, double %5)
64+
%9 = fptoui double %8 to i32
65+
ret i32 %9
66+
67+
; CHECK-LABEL: __muldf3
68+
; CHECK-LABEL: __adddf3
69+
}
70+
71+
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
72+
declare double @llvm.fmuladd.f64(double, double, double) #1
73+
5474
attributes #0 = {"use-soft-float"="true" }
75+
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

0 commit comments

Comments
 (0)