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

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 12:39:37 PDT 2015


Author: spatel
Date: Tue Aug 11 14:39:36 2015
New Revision: 244651

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

Also, add a test for optsize because this was not part of any existing regression test.


Modified:
    llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
    llvm/trunk/test/CodeGen/X86/slow-div.ll

Modified: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp?rev=244651&r1=244650&r2=244651&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Tue Aug 11 14:39:36 2015
@@ -214,8 +214,7 @@ bool CodeGenPrepare::runOnFunction(Funct
     TLI = TM->getSubtargetImpl(F)->getTargetLowering();
   TLInfo = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
   TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
-  // FIXME: Use Function::optForSize().
-  OptSize = F.hasFnAttribute(Attribute::OptimizeForSize);
+  OptSize = F.optForSize();
 
   /// This optimization identifies DIV instructions that can be
   /// profitably bypassed and carried out with a shorter, faster divide.

Modified: llvm/trunk/test/CodeGen/X86/slow-div.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/slow-div.ll?rev=244651&r1=244650&r2=244651&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/slow-div.ll (original)
+++ llvm/trunk/test/CodeGen/X86/slow-div.ll Tue Aug 11 14:39:36 2015
@@ -25,4 +25,19 @@ entry:
   ret i64 %div
 }
 
+; Verify that no extra code is generated when optimizing for size.
+
+define i32 @div32_optsize(i32 %a, i32 %b) optsize {
+; DIV32-LABEL: div32_optsize:
+; DIV32-NOT: divb
+  %div = sdiv i32 %a, %b
+  ret i32 %div
+}
+
+define i32 @div32_minsize(i32 %a, i32 %b) minsize {
+; DIV32-LABEL: div32_minsize:
+; DIV32-NOT: divb
+  %div = sdiv i32 %a, %b
+  ret i32 %div
+}
 




More information about the llvm-commits mailing list