<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 10, 2015, at 5:53 AM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">----- Original Message -----</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">From: "Michael Zolotukhin" <<a href="mailto:mzolotukhin@apple.com" class="">mzolotukhin@apple.com</a>><br class="">To: "Hal J. Finkel" <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>><br class="">Cc:<span class="Apple-converted-space"> </span><a href="mailto:llvm-commits@cs.uiuc.edu" class="">llvm-commits@cs.uiuc.edu</a><br class="">Sent: Monday, February 9, 2015 2:49:40 PM<br class="">Subject: Re: [llvm] r228434 - Use estimated number of optimized insns in unroll-threshold computation.<br class=""><br class=""><br class=""><br class="">Hi Hal,<br class=""><br class="">Could you please take a look at the attached test? Does it cover the<br class="">new features enough, or did I miss anything?<br class=""><br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I think this looks good. Please commit it.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote>Thanks, committed in r228713.</div><div><br class=""></div><div>Michael<br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">-Hal</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="">Thanks,<br class="">Michael<br class=""><br class=""><blockquote type="cite" class="">On Feb 6, 2015, at 12:31 PM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>> wrote:<br class=""><br class="">As you stated in your follow-up e-mail ;) -- this needs a test<br class="">case.<br class=""><br class="">-Hal<br class=""><br class="">----- Original Message -----<br class=""><blockquote type="cite" class="">From: "Michael Zolotukhin" <<a href="mailto:mzolotukhin@apple.com" class="">mzolotukhin@apple.com</a>><br class="">To: <a href="mailto:llvm-commits@cs.uiuc.edu" class="">llvm-commits@cs.uiuc.edu</a><br class="">Sent: Friday, February 6, 2015 2:20:40 PM<br class="">Subject: [llvm] r228434 - Use estimated number of optimized insns<br class="">in unroll-threshold computation.<br class=""><br class="">Author: mzolotukhin<br class="">Date: Fri Feb 6 14:20:40 2015<br class="">New Revision: 228434<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=228434&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=228434&view=rev</a><br class="">Log:<br class="">Use estimated number of optimized insns in unroll-threshold<br class="">computation.<br class=""><br class="">If complete-unroll could help us to optimize away N% of<br class="">instructions,<br class="">we<br class="">might want to do this even if the final size would exceed<br class="">loop-unroll<br class="">threshold. However, we don't want to unroll huge loop, and we are<br class="">add<br class="">AbsoluteThreshold to avoid that - this threshold will never be<br class="">crossed,<br class="">even if we expect to optimize 99% instructions after that.<br class=""><br class="">Modified:<br class="">llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h<br class="">llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp<br class=""><br class="">Modified: llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h<br class="">URL:<br class=""><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h?rev=228434&r1=228433&r2=228434&view=diff" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h?rev=228434&r1=228433&r2=228434&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h<br class="">(original)<br class="">+++ llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h Fri Feb<br class="">6<br class="">14:20:40 2015<br class="">@@ -217,6 +217,13 @@ public:<br class="">/// exceed this cost. Set this to UINT_MAX to disable the loop<br class="">body cost<br class="">/// restriction.<br class="">unsigned Threshold;<br class="">+ /// If complete unrolling could help other optimizations (e.g.<br class="">InstSimplify)<br class="">+ /// to remove N% of instructions, then we can go beyond unroll<br class="">threshold.<br class="">+ /// This value set the minimal percent for allowing that.<br class="">+ unsigned MinPercentOfOptimized;<br class="">+ /// The absolute cost threshold. We won't go beyond this even if<br class="">complete<br class="">+ /// unrolling could result in optimizing out 90% of<br class="">instructions.<br class="">+ unsigned AbsoluteThreshold;<br class="">/// The cost threshold for the unrolled loop when optimizing for<br class="">size (set<br class="">/// to UINT_MAX to disable).<br class="">unsigned OptSizeThreshold;<br class=""><br class="">Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp<br class="">URL:<br class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp?rev=228434&r1=228433&r2=228434&view=diff<br class="">==============================================================================<br class="">--- llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp (original)<br class="">+++ llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp Fri Feb 6<br class="">14:20:40 2015<br class="">@@ -45,6 +45,17 @@ static cl::opt<unsigned> UnrollMaxIterat<br class="">cl::desc("Don't allow loop unrolling to simulate more than this<br class="">number of"<br class="">"iterations when checking full unroll profitability"));<br class=""><br class="">+static cl::opt<unsigned> UnrollMinPercentOfOptimized(<br class="">+ "unroll-percent-of-optimized-for-complete-unroll", cl::init(20),<br class="">cl::Hidden,<br class="">+ cl::desc("If complete unrolling could trigger further<br class="">optimizations, and, "<br class="">+ "by that, remove the given percent of instructions,<br class="">perform the "<br class="">+ "complete unroll even if it's beyond the threshold"));<br class="">+<br class="">+static cl::opt<unsigned> UnrollAbsoluteThreshold(<br class="">+ "unroll-absolute-threshold", cl::init(2000), cl::Hidden,<br class="">+ cl::desc("Don't unroll if the unrolled size is bigger than this<br class="">threshold,"<br class="">+ " even if we can remove big portion of instructions<br class="">later."));<br class="">+<br class="">static cl::opt<unsigned><br class="">UnrollCount("unroll-count", cl::init(0), cl::Hidden,<br class="">cl::desc("Use this unroll count for all loops including those with<br class="">"<br class="">@@ -70,11 +81,16 @@ namespace {<br class="">static char ID; // Pass ID, replacement for typeid<br class="">LoopUnroll(int T = -1, int C = -1, int P = -1, int R = -1) :<br class="">LoopPass(ID) {<br class="">CurrentThreshold = (T == -1) ? UnrollThreshold : unsigned(T);<br class="">+ CurrentAbsoluteThreshold = UnrollAbsoluteThreshold;<br class="">+ CurrentMinPercentOfOptimized = UnrollMinPercentOfOptimized;<br class="">CurrentCount = (C == -1) ? UnrollCount : unsigned(C);<br class="">CurrentAllowPartial = (P == -1) ? UnrollAllowPartial :<br class="">(bool)P;<br class="">CurrentRuntime = (R == -1) ? UnrollRuntime : (bool)R;<br class=""><br class="">UserThreshold = (T != -1) ||<br class="">(UnrollThreshold.getNumOccurrences() > 0);<br class="">+ UserAbsoluteThreshold =<br class="">(UnrollAbsoluteThreshold.getNumOccurrences() > 0);<br class="">+ UserPercentOfOptimized =<br class="">+ (UnrollMinPercentOfOptimized.getNumOccurrences() > 0);<br class="">UserAllowPartial = (P != -1) ||<br class="">(UnrollAllowPartial.getNumOccurrences() ><br class="">0);<br class="">UserRuntime = (R != -1) || (UnrollRuntime.getNumOccurrences()<br class=""><blockquote type="cite" class="">0);<br class=""></blockquote>@@ -98,10 +114,16 @@ namespace {<br class=""><br class="">unsigned CurrentCount;<br class="">unsigned CurrentThreshold;<br class="">+ unsigned CurrentAbsoluteThreshold;<br class="">+ unsigned CurrentMinPercentOfOptimized;<br class="">bool CurrentAllowPartial;<br class="">bool CurrentRuntime;<br class="">bool UserCount; // CurrentCount is<br class="">user-specified.<br class="">bool UserThreshold; // CurrentThreshold is<br class="">user-specified.<br class="">+ bool UserAbsoluteThreshold; // CurrentAbsoluteThreshold is<br class="">+ // user-specified.<br class="">+ bool UserPercentOfOptimized; // CurrentMinPercentOfOptimized<br class="">is<br class="">+ // user-specified.<br class="">bool UserAllowPartial; // CurrentAllowPartial is<br class="">user-specified.<br class="">bool UserRuntime; // CurrentRuntime is<br class="">user-specified.<br class=""><br class="">@@ -133,6 +155,8 @@ namespace {<br class="">void getUnrollingPreferences(Loop *L, const TargetTransformInfo<br class="">&TTI,<br class="">TargetTransformInfo::UnrollingPreferences<br class="">&UP) {<br class="">UP.Threshold = CurrentThreshold;<br class="">+ UP.AbsoluteThreshold = CurrentAbsoluteThreshold;<br class="">+ UP.MinPercentOfOptimized = CurrentMinPercentOfOptimized;<br class="">UP.OptSizeThreshold = OptSizeUnrollThreshold;<br class="">UP.PartialThreshold = CurrentThreshold;<br class="">UP.PartialOptSizeThreshold = OptSizeUnrollThreshold;<br class="">@@ -160,13 +184,32 @@ namespace {<br class="">void selectThresholds(const Loop *L, bool HasPragma,<br class="">const<br class="">TargetTransformInfo::UnrollingPreferences<br class="">&UP,<br class="">unsigned &Threshold, unsigned<br class="">&PartialThreshold,<br class="">- unsigned NumberOfSimplifiedInstructions) {<br class="">+ unsigned NumberOfOptimizedInstructions) {<br class="">// Determine the current unrolling threshold. While this is<br class="">// normally set from UnrollThreshold, it is overridden to a<br class="">// smaller value if the current function is marked as<br class="">// optimize-for-size, and the unroll threshold was not user<br class="">// specified.<br class="">Threshold = UserThreshold ? CurrentThreshold : UP.Threshold;<br class="">+<br class="">+ // If we are allowed to completely unroll if we can remove M%<br class="">of<br class="">+ // instructions, and we know that with complete unrolling<br class="">we'll be able<br class="">+ // to kill N instructions, then we can afford to completely<br class="">unroll loops<br class="">+ // with unrolled size up to N*100/M.<br class="">+ // Adjust the threshold according to that:<br class="">+ unsigned PercentOfOptimizedForCompleteUnroll =<br class="">+ UserPercentOfOptimized ? CurrentMinPercentOfOptimized<br class="">+ : UP.MinPercentOfOptimized;<br class="">+ unsigned AbsoluteThreshold = UserAbsoluteThreshold<br class="">+ ? CurrentAbsoluteThreshold<br class="">+ : UP.AbsoluteThreshold;<br class="">+ if (PercentOfOptimizedForCompleteUnroll)<br class="">+ Threshold = std::max<unsigned>(Threshold,<br class="">+ NumberOfOptimizedInstructions<br class="">* 100 /<br class="">+<br class="">PercentOfOptimizedForCompleteUnroll);<br class="">+ // But don't allow unrolling loops bigger than absolute<br class="">threshold.<br class="">+ Threshold = std::min<unsigned>(Threshold, AbsoluteThreshold);<br class="">+<br class="">PartialThreshold = UserThreshold ? CurrentThreshold :<br class="">UP.PartialThreshold;<br class="">if (!UserThreshold &&<br class="">L->getHeader()->getParent()->getAttributes().<br class="">@@ -186,7 +229,6 @@ namespace {<br class="">PartialThreshold =<br class="">std::max<unsigned>(PartialThreshold,<br class="">PragmaUnrollThreshold);<br class="">}<br class="">- Threshold += NumberOfSimplifiedInstructions;<br class="">}<br class="">};<br class="">}<br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class="">llvm-commits@cs.uiuc.edu<br class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br class=""><br class=""></blockquote><br class="">--<br class="">Hal Finkel<br class="">Assistant Computational Scientist<br class="">Leadership Computing Facility<br class="">Argonne National Laboratory<br class=""></blockquote><br class=""><br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">--<span class="Apple-converted-space"> </span></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Hal Finkel</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Assistant Computational Scientist</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Leadership Computing Facility</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Argonne National Laboratory</span></div></blockquote></div><br class=""></body></html>