From b549ab02b4659c2e6164cb1a39ef798b80d643df Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sat, 26 Mar 2016 09:42:31 +0000 Subject: [PATCH] [PowerPC] Disable the CTR optimization in the presence of {min,max}num The minnum and maxnum intrinsics get lowered to libcalls which invalidates the CTR optimization. This fixes PR27083. llvm-svn: 264508 --- llvm/lib/Target/PowerPC/PPCCTRLoops.cpp | 2 ++ llvm/test/CodeGen/PowerPC/ctr-minmaxnum.ll | 44 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 llvm/test/CodeGen/PowerPC/ctr-minmaxnum.ll diff --git a/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp b/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp index b0a3e93..2a1cb60 100644 --- a/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp +++ b/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp @@ -291,6 +291,8 @@ bool PPCCTRLoops::mightUseCTR(const Triple &TT, BasicBlock *BB) { case Intrinsic::pow: case Intrinsic::sin: case Intrinsic::cos: + case Intrinsic::maxnum: + case Intrinsic::minnum: return true; case Intrinsic::copysign: if (CI->getArgOperand(0)->getType()->getScalarType()-> diff --git a/llvm/test/CodeGen/PowerPC/ctr-minmaxnum.ll b/llvm/test/CodeGen/PowerPC/ctr-minmaxnum.ll new file mode 100644 index 0000000..c109b43 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/ctr-minmaxnum.ll @@ -0,0 +1,44 @@ +; RUN: llc < %s | FileCheck %s +target triple = "powerpc64le-unknown-linux-gnu" + +define void @test1(float %f, float* %fp) { +entry: + br label %loop_body + +loop_body: + %invar_address.dim.0.01 = phi i64 [ 0, %entry ], [ %1, %loop_body ] + %0 = call float @llvm.minnum.f32(float %f, float 1.0) + store float %0, float* %fp, align 4 + %1 = add i64 %invar_address.dim.0.01, 1 + %2 = icmp eq i64 %1, 2 + br i1 %2, label %loop_exit, label %loop_body + +loop_exit: + ret void +} + +; CHECK-LABEL: test1: +; CHECK: bl fminf + + +define void @test2(float %f, float* %fp) { +entry: + br label %loop_body + +loop_body: + %invar_address.dim.0.01 = phi i64 [ 0, %entry ], [ %1, %loop_body ] + %0 = call float @llvm.maxnum.f32(float %f, float 1.0) + store float %0, float* %fp, align 4 + %1 = add i64 %invar_address.dim.0.01, 1 + %2 = icmp eq i64 %1, 2 + br i1 %2, label %loop_exit, label %loop_body + +loop_exit: + ret void +} + +; CHECK-LABEL: test2: +; CHECK: bl fmaxf + +declare float @llvm.minnum.f32(float, float) +declare float @llvm.maxnum.f32(float, float) -- 2.7.4