diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp index 56ae5c010411..bc0f1e9f400c 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -209,10 +209,7 @@ namespace { ? CurrentDynamicCostSavingsDiscount : UP.DynamicCostSavingsDiscount; - if (!UserThreshold && - // FIXME: Use Function::optForSize(). - L->getHeader()->getParent()->hasFnAttribute( - Attribute::OptimizeForSize)) { + if (!UserThreshold && L->getHeader()->getParent()->optForSize()) { Threshold = UP.OptSizeThreshold; PartialThreshold = UP.PartialOptSizeThreshold; } diff --git a/llvm/test/Transforms/LoopUnroll/partial-unroll-optsize.ll b/llvm/test/Transforms/LoopUnroll/partial-unroll-optsize.ll index a650317f3df7..e5e0151761bf 100644 --- a/llvm/test/Transforms/LoopUnroll/partial-unroll-optsize.ll +++ b/llvm/test/Transforms/LoopUnroll/partial-unroll-optsize.ll @@ -1,4 +1,6 @@ ; RUN: opt < %s -S -loop-unroll -unroll-allow-partial | FileCheck %s +; RUN: sed -e 's/optsize/minsize/' %s | opt -S -loop-unroll -unroll-allow-partial | FileCheck %s + ; Loop size = 3, when the function has the optsize attribute, the ; OptSizeUnrollThreshold, i.e. 50, is used, hence the loop should be unrolled ; by 32 times because (1 * 32) + 2 < 50 (whereas (1 * 64 + 2) is not). @@ -49,4 +51,3 @@ exit: ; CHECK-NEXT: add ; CHECK-NEXT: add ; CHECK-NEXT: icmp -