From 47db66d43fd441eb8d619036fb5440a7fc69fb3f Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Thu, 16 May 2013 16:52:41 +0000 Subject: PPC32 cannot form counter loops around i64 FP conversions On PPC32, i64 FP conversions are implemented using runtime calls (which clobber the counter register). These must be excluded. llvm-svn: 182023 --- llvm/lib/Target/PowerPC/PPCCTRLoops.cpp | 6 +++++- llvm/test/CodeGen/PowerPC/ctrloop-fp64.ll | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 llvm/test/CodeGen/PowerPC/ctrloop-fp64.ll (limited to 'llvm') diff --git a/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp b/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp index ae5d9184605..6bbd571894d 100644 --- a/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp +++ b/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp @@ -305,7 +305,11 @@ bool PPCCTRLoops::convertToCTRLoop(Loop *L) { isa(J) || isa(J)) { CastInst *CI = cast(J); if (CI->getSrcTy()->getScalarType()->isPPC_FP128Ty() || - CI->getDestTy()->getScalarType()->isPPC_FP128Ty()) + CI->getDestTy()->getScalarType()->isPPC_FP128Ty() || + (TT.isArch32Bit() && + (CI->getSrcTy()->getScalarType()->isIntegerTy(64) || + CI->getDestTy()->getScalarType()->isIntegerTy(64)) + )) return MadeChange; } else if (isa(J) || isa(J)) { // On PowerPC, indirect jumps use the counter register. diff --git a/llvm/test/CodeGen/PowerPC/ctrloop-fp64.ll b/llvm/test/CodeGen/PowerPC/ctrloop-fp64.ll new file mode 100644 index 00000000000..78974248da5 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/ctrloop-fp64.ll @@ -0,0 +1,28 @@ +; RUN: llc < %s -mcpu=generic | FileCheck %s + +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" +target triple = "powerpc-unknown-linux-gnu" + +define i64 @foo(double* nocapture %n) nounwind readonly { +entry: + br label %for.body + +for.body: ; preds = %for.body, %entry + %i.06 = phi i32 [ 0, %entry ], [ %inc, %for.body ] + %x.05 = phi i64 [ 0, %entry ], [ %conv1, %for.body ] + %arrayidx = getelementptr inbounds double* %n, i32 %i.06 + %0 = load double* %arrayidx, align 8 + %conv = sitofp i64 %x.05 to double + %add = fadd double %conv, %0 + %conv1 = fptosi double %add to i64 + %inc = add nsw i32 %i.06, 1 + %exitcond = icmp eq i32 %inc, 2048 + br i1 %exitcond, label %for.end, label %for.body + +for.end: ; preds = %for.body + ret i64 %conv1 +} + +; CHECK: @foo +; CHECK-NOT: mtctr + -- cgit v1.2.3