[llvm] r293041 - Mark @llvm.powi.* as safe to speculatively execute.

whitequark via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 01:32:31 PST 2017


Author: whitequark
Date: Wed Jan 25 03:32:30 2017
New Revision: 293041

URL: http://llvm.org/viewvc/llvm-project?rev=293041&view=rev
Log:
Mark @llvm.powi.* as safe to speculatively execute.

Floating point intrinsics in LLVM are generally not speculatively
executed, since most of them are defined to behave the same as libm
functions, which set errno.

However, the @llvm.powi.* intrinsics do not correspond to any libm
function, and lacks any defined error handling semantics in LangRef.
It most certainly does not alter errno.

Modified:
    llvm/trunk/lib/Analysis/ValueTracking.cpp
    llvm/trunk/test/Transforms/LICM/hoist-round.ll

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=293041&r1=293040&r2=293041&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Wed Jan 25 03:32:30 2017
@@ -3339,6 +3339,10 @@ bool llvm::isSafeToSpeculativelyExecute(
       case Intrinsic::rint:
       case Intrinsic::round:
         return true;
+      // These intrinsics do not correspond to any libm function, and
+      // do not set errno.
+      case Intrinsic::powi:
+        return true;
       // TODO: are convert_{from,to}_fp16 safe?
       // TODO: can we list target-specific intrinsics here?
       default: break;

Modified: llvm/trunk/test/Transforms/LICM/hoist-round.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LICM/hoist-round.ll?rev=293041&r1=293040&r2=293041&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LICM/hoist-round.ll (original)
+++ llvm/trunk/test/Transforms/LICM/hoist-round.ll Wed Jan 25 03:32:30 2017
@@ -18,6 +18,7 @@ target datalayout = "E-m:e-p:32:32-i8:8:
 ; CHECK: call float @llvm.copysign.f32
 ; CHECK: call float @llvm.minnum.f32
 ; CHECK: call float @llvm.maxnum.f32
+; CHECK: call float @llvm.powi.f32
 ; CHECK: for.body:
 
 define void @test(float %arg1, float %arg2) {
@@ -40,7 +41,8 @@ for.body:
   %tmp.8 = call float @llvm.copysign.f32(float %tmp.7, float %arg2)
   %tmp.9 = call float @llvm.minnum.f32(float %tmp.8, float %arg2)
   %tmp.10 = call float @llvm.maxnum.f32(float %tmp.9, float %arg2)
-  call void @consume(float %tmp.10)
+  %tmp.11 = call float @llvm.powi.f32(float %tmp.10, i32 4)
+  call void @consume(float %tmp.11)
   %IND.new = add i32 %IND, 1
   br label %for.head
 
@@ -60,3 +62,4 @@ declare float @llvm.fabs.f32(float)
 declare float @llvm.copysign.f32(float, float)
 declare float @llvm.minnum.f32(float, float)
 declare float @llvm.maxnum.f32(float, float)
+declare float @llvm.powi.f32(float, i32)




More information about the llvm-commits mailing list