Skip to content

Commit 1cf48ab

Browse files
author
Hal Finkel
committed
Don't form PPC CTR-based loops around a copysignl call
copysign/copysignf never become function calls (because the SDAG expansion code does not lower to the corresponding function call, but rather directly implements the associated logic), but copysignl almost always is lowered into a call to the requested libm functon (and, thus, might clobber CTR). llvm-svn: 188727
1 parent 4612fed commit 1cf48ab

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

llvm/lib/Target/PowerPC/PPCCTRLoops.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,9 @@ bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) {
284284
default: return true;
285285
case LibFunc::copysign:
286286
case LibFunc::copysignf:
287-
case LibFunc::copysignl:
288287
continue; // ISD::FCOPYSIGN is never a library call.
288+
case LibFunc::copysignl:
289+
return true;
289290
case LibFunc::fabs:
290291
case LibFunc::fabsf:
291292
case LibFunc::fabsl:
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; RUN: llc < %s -mcpu=ppc | FileCheck %s
2+
3+
target datalayout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32"
4+
target triple = "powerpc-unknown-linux-gnu"
5+
6+
define ppc_fp128 @foo(ppc_fp128* nocapture %n, ppc_fp128 %d) nounwind readonly {
7+
entry:
8+
br label %for.body
9+
10+
for.body: ; preds = %for.body, %entry
11+
%i.06 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
12+
%x.05 = phi ppc_fp128 [ %d, %entry ], [ %conv, %for.body ]
13+
%arrayidx = getelementptr inbounds ppc_fp128* %n, i32 %i.06
14+
%0 = load ppc_fp128* %arrayidx, align 8
15+
%conv = tail call ppc_fp128 @copysignl(ppc_fp128 %x.05, ppc_fp128 %d) nounwind readonly
16+
%inc = add nsw i32 %i.06, 1
17+
%exitcond = icmp eq i32 %inc, 2048
18+
br i1 %exitcond, label %for.end, label %for.body
19+
20+
for.end: ; preds = %for.body
21+
ret ppc_fp128 %conv
22+
}
23+
24+
declare ppc_fp128 @copysignl(ppc_fp128, ppc_fp128) #0
25+
26+
; CHECK: @foo
27+
; CHECK-NOT: mtctr
28+

0 commit comments

Comments
 (0)