[llvm] r264508 - [PowerPC] Disable the CTR optimization in the presence of {min, max}num

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 26 22:50:12 PDT 2016


----- Original Message -----
> From: "David Majnemer via llvm-commits" <llvm-commits at lists.llvm.org>
> To: llvm-commits at lists.llvm.org
> Sent: Saturday, March 26, 2016 4:42:31 AM
> Subject: [llvm] r264508 - [PowerPC] Disable the CTR optimization in the presence of {min, max}num
> 
> Author: majnemer
> Date: Sat Mar 26 04:42:31 2016
> New Revision: 264508
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=264508&view=rev
> Log:
> [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.

Thanks! I generalized this a bit in r264532 (which started as a pure follow-on to this commit, but ended up being a bit more general because, in doing so, I realized that the entire intrinsic -> ISD opcode mapping check was broken).

 -Hal

> 
> Added:
>     llvm/trunk/test/CodeGen/PowerPC/ctr-minmaxnum.ll
> Modified:
>     llvm/trunk/lib/Target/PowerPC/PPCCTRLoops.cpp
> 
> Modified: llvm/trunk/lib/Target/PowerPC/PPCCTRLoops.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCCTRLoops.cpp?rev=264508&r1=264507&r2=264508&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/PowerPC/PPCCTRLoops.cpp (original)
> +++ llvm/trunk/lib/Target/PowerPC/PPCCTRLoops.cpp Sat Mar 26 04:42:31
> 2016
> @@ -291,6 +291,8 @@ bool PPCCTRLoops::mightUseCTR(const Trip
>            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()->
> 
> Added: llvm/trunk/test/CodeGen/PowerPC/ctr-minmaxnum.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ctr-minmaxnum.ll?rev=264508&view=auto
> ==============================================================================
> --- llvm/trunk/test/CodeGen/PowerPC/ctr-minmaxnum.ll (added)
> +++ llvm/trunk/test/CodeGen/PowerPC/ctr-minmaxnum.ll Sat Mar 26
> 04:42:31 2016
> @@ -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)
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory


More information about the llvm-commits mailing list