[llvm] r244631 - fix minsize detection: minsize attribute implies optimizing for size

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 10:04:32 PDT 2015


Author: spatel
Date: Tue Aug 11 12:04:31 2015
New Revision: 244631

URL: http://llvm.org/viewvc/llvm-project?rev=244631&view=rev
Log:
fix minsize detection: minsize attribute implies optimizing for size

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    llvm/trunk/test/CodeGen/X86/powi.ll

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=244631&r1=244630&r2=244631&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Aug 11 12:04:31 2015
@@ -3971,10 +3971,9 @@ static SDValue ExpandPowI(SDLoc DL, SDVa
       return DAG.getConstantFP(1.0, DL, LHS.getValueType());
 
     const Function *F = DAG.getMachineFunction().getFunction();
-    // FIXME: Use Function::optForSize().
-    if (!F->hasFnAttribute(Attribute::OptimizeForSize) ||
-        // If optimizing for size, don't insert too many multiplies.  This
-        // inserts up to 5 multiplies.
+    if (!F->optForSize() ||
+        // If optimizing for size, don't insert too many multiplies.
+        // This inserts up to 5 multiplies.
         countPopulation(Val) + Log2_32(Val) < 7) {
       // We use the simple binary decomposition method to generate the multiply
       // sequence.  There are more optimal ways to do this (for example,

Modified: llvm/trunk/test/CodeGen/X86/powi.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/powi.ll?rev=244631&r1=244630&r2=244631&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/powi.ll (original)
+++ llvm/trunk/test/CodeGen/X86/powi.ll Tue Aug 11 12:04:31 2015
@@ -17,7 +17,7 @@ define double @pow_wrapper(double %a) no
   ret double %ret
 }
 
-define double @pow_wrapper_optsize(double %a) optsize  {
+define double @pow_wrapper_optsize(double %a) optsize {
 ; CHECK-LABEL: pow_wrapper_optsize:
 ; CHECK:       # BB#0:
 ; CHECK-NEXT:    movl  $15, %edi
@@ -26,20 +26,11 @@ define double @pow_wrapper_optsize(doubl
   ret double %ret
 }
 
-; FIXME: Should not expand with minsize
-
-define double @pow_wrapper_minsize(double %a) minsize  {
+define double @pow_wrapper_minsize(double %a) minsize {
 ; CHECK-LABEL: pow_wrapper_minsize:
 ; CHECK:       # BB#0:
-; CHECK-NEXT:    movapd %xmm0, %xmm1
-; CHECK-NEXT:    mulsd %xmm1, %xmm1
-; CHECK-NEXT:    mulsd %xmm1, %xmm0
-; CHECK-NEXT:    mulsd %xmm1, %xmm1
-; CHECK-NEXT:    mulsd %xmm1, %xmm0
-; CHECK-NEXT:    mulsd %xmm1, %xmm1
-; CHECK-NEXT:    mulsd %xmm0, %xmm1
-; CHECK-NEXT:    movapd %xmm1, %xmm0
-; CHECK-NEXT:    retq
+; CHECK-NEXT:    movl  $15, %edi
+; CHECK-NEXT:    jmp
   %ret = tail call double @llvm.powi.f64(double %a, i32 15) nounwind ; <double> [#uses=1]
   ret double %ret
 }




More information about the llvm-commits mailing list