<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""></div><div class=""><br class=""></div><div class="">Is it ok to commit it?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Michael</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 6, 2015, at 12:23 PM, Michael Zolotukhin <<a href="mailto:mzolotukhin@apple.com" class="">mzolotukhin@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="" 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="">On Feb 6, 2015, at 12:10 PM, Chad Rosier <<a href="mailto:mcrosier@codeaurora.org" class="">mcrosier@codeaurora.org</a>> wrote:<br class=""><br class="">testcase?<br class=""></blockquote><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’ll follow up shortly with that.</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=""><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="">Thanks,</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="">Michael</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=""><blockquote type="cite" class="">Author: mzolotukhin<br class="">Date: Fri Feb  6 14:02:51 2015<br class="">New Revision: 228432<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=228432&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=228432&view=rev</a><br class="">Log:<br class="">[InstSimplify] Add SimplifyFPBinOp function.<br class=""><br class="">It is a variation of SimplifyBinOp, but it takes into account<br class="">FastMathFlags.<br class=""><br class="">It is needed in inliner and loop-unroller to accurately predict the<br class="">transformation's outcome (previously we dropped the flags and were too<br class="">conservative in some cases).<br class=""><br class="">Example:<br class="">float foo(float *a, float b) {<br class="">float r;<br class="">if (a[1] * b)<br class=""> r = /* a lot of expensive computations */;<br class="">else<br class=""> r = 1;<br class="">return r;<br class="">}<br class="">float boo(float *a) {<br class="">return foo(a, 0.0);<br class="">}<br class=""><br class="">Without this patch, we don't inline 'foo' into 'boo'.<br class=""><br class="">Modified:<br class="">  llvm/trunk/include/llvm/Analysis/InstructionSimplify.h<br class="">  llvm/trunk/lib/Analysis/IPA/InlineCost.cpp<br class="">  llvm/trunk/lib/Analysis/InstructionSimplify.cpp<br class="">  llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp<br class=""><br class="">Modified: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h<br class="">URL:<br class=""><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InstructionSimplify.h?rev=228432&r1=228431&r2=228432&view=diff" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InstructionSimplify.h?rev=228432&r1=228431&r2=228432&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/include/llvm/Analysis/InstructionSimplify.h (original)<br class="">+++ llvm/trunk/include/llvm/Analysis/InstructionSimplify.h Fri Feb  6<br class="">14:02:51 2015<br class="">@@ -277,6 +277,17 @@ namespace llvm {<br class="">                      const DominatorTree *DT = nullptr,<br class="">                      AssumptionCache *AC = nullptr,<br class="">                      const Instruction *CxtI = nullptr);<br class="">+  /// SimplifyFPBinOp - Given operands for a BinaryOperator, see if we<br class="">can<br class="">+  /// fold the result.  If not, this returns null.<br class="">+  /// In contrast to SimplifyBinOp, try to use FastMathFlag when folding<br class="">the<br class="">+  /// result. In case we don't need FastMathFlags, simply fall to<br class="">SimplifyBinOp.<br class="">+  Value *SimplifyFPBinOp(unsigned Opcode, Value *LHS, Value *RHS,<br class="">+                         const FastMathFlags &FMF,<br class="">+                         const DataLayout *TD = nullptr,<br class="">+                         const TargetLibraryInfo *TLI = nullptr,<br class="">+                         const DominatorTree *DT = nullptr,<br class="">+                         AssumptionCache *AC = nullptr,<br class="">+                         const Instruction *CxtI = nullptr);<br class=""><br class=""> /// \brief Given a function and iterators over arguments, see if we can<br class="">fold<br class=""> /// the result.<br class=""><br class="">Modified: llvm/trunk/lib/Analysis/IPA/InlineCost.cpp<br class="">URL:<br class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/InlineCost.cpp?rev=228432&r1=228431&r2=228432&view=diff<br class="">==============================================================================<br class="">--- llvm/trunk/lib/Analysis/IPA/InlineCost.cpp (original)<br class="">+++ llvm/trunk/lib/Analysis/IPA/InlineCost.cpp Fri Feb  6 14:02:51 2015<br class="">@@ -601,7 +601,13 @@ bool CallAnalyzer::visitBinaryOperator(B<br class=""> if (!isa<Constant>(RHS))<br class="">   if (Constant *SimpleRHS = SimplifiedValues.lookup(RHS))<br class="">     RHS = SimpleRHS;<br class="">-  Value *SimpleV = SimplifyBinOp(I.getOpcode(), LHS, RHS, DL);<br class="">+  Value *SimpleV = nullptr;<br class="">+  if (auto FI = dyn_cast<FPMathOperator>(&I))<br class="">+    SimpleV =<br class="">+        SimplifyFPBinOp(I.getOpcode(), LHS, RHS, FI->getFastMathFlags(),<br class="">DL);<br class="">+  else<br class="">+    SimpleV = SimplifyBinOp(I.getOpcode(), LHS, RHS, DL);<br class="">+<br class=""> if (Constant *C = dyn_cast_or_null<Constant>(SimpleV)) {<br class="">   SimplifiedValues[&I] = C;<br class="">   return true;<br class=""><br class="">Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp<br class="">URL:<br class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=228432&r1=228431&r2=228432&view=diff<br class="">==============================================================================<br class="">--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)<br class="">+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Fri Feb  6 14:02:51<br class="">2015<br class="">@@ -61,6 +61,8 @@ struct Query {<br class="">static Value *SimplifyAndInst(Value *, Value *, const Query &, unsigned);<br class="">static Value *SimplifyBinOp(unsigned, Value *, Value *, const Query &,<br class="">                           unsigned);<br class="">+static Value *SimplifyFPBinOp(unsigned, Value *, Value *, const<br class="">FastMathFlags &,<br class="">+                              const Query &, unsigned);<br class="">static Value *SimplifyCmpInst(unsigned, Value *, Value *, const Query &,<br class="">                             unsigned);<br class="">static Value *SimplifyOrInst(Value *, Value *, const Query &, unsigned);<br class="">@@ -3465,6 +3467,25 @@ static Value *SimplifyBinOp(unsigned Opc<br class=""> }<br class="">}<br class=""><br class="">+/// SimplifyFPBinOp - Given operands for a BinaryOperator, see if we can<br class="">+/// fold the result.  If not, this returns null.<br class="">+/// In contrast to SimplifyBinOp, try to use FastMathFlag when folding<br class="">the<br class="">+/// result. In case we don't need FastMathFlags, simply fall to<br class="">SimplifyBinOp.<br class="">+static Value *SimplifyFPBinOp(unsigned Opcode, Value *LHS, Value *RHS,<br class="">+                              const FastMathFlags &FMF, const Query &Q,<br class="">+                              unsigned MaxRecurse) {<br class="">+  switch (Opcode) {<br class="">+  case Instruction::FAdd:<br class="">+    return SimplifyFAddInst(LHS, RHS, FMF, Q, MaxRecurse);<br class="">+  case Instruction::FSub:<br class="">+    return SimplifyFSubInst(LHS, RHS, FMF, Q, MaxRecurse);<br class="">+  case Instruction::FMul:<br class="">+    return SimplifyFMulInst(LHS, RHS, FMF, Q, MaxRecurse);<br class="">+  default:<br class="">+    return SimplifyBinOp(Opcode, LHS, RHS, Q, MaxRecurse);<br class="">+  }<br class="">+}<br class="">+<br class="">Value *llvm::SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS,<br class="">                          const DataLayout *DL, const TargetLibraryInfo<br class="">*TLI,<br class="">                          const DominatorTree *DT, AssumptionCache *AC,<br class="">@@ -3473,6 +3494,15 @@ Value *llvm::SimplifyBinOp(unsigned Opco<br class="">                        RecursionLimit);<br class="">}<br class=""><br class="">+Value *llvm::SimplifyFPBinOp(unsigned Opcode, Value *LHS, Value *RHS,<br class="">+                             const FastMathFlags &FMF, const DataLayout<br class="">*DL,<br class="">+                             const TargetLibraryInfo *TLI,<br class="">+                             const DominatorTree *DT, AssumptionCache<br class="">*AC,<br class="">+                             const Instruction *CxtI) {<br class="">+  return ::SimplifyFPBinOp(Opcode, LHS, RHS, FMF, Query(DL, TLI, DT, AC,<br class="">CxtI),<br class="">+                           RecursionLimit);<br class="">+}<br class="">+<br class="">/// SimplifyCmpInst - Given operands for a CmpInst, see if we can<br class="">/// fold the result.<br class="">static Value *SimplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS,<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=228432&r1=228431&r2=228432&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:02:51 2015<br class="">@@ -311,7 +311,12 @@ class UnrollAnalyzer : public InstVisito<br class="">   if (!isa<Constant>(RHS))<br class="">     if (Constant *SimpleRHS = SimplifiedValues.lookup(RHS))<br class="">       RHS = SimpleRHS;<br class="">-    Value *SimpleV = SimplifyBinOp(I.getOpcode(), LHS, RHS);<br class="">+    Value *SimpleV = nullptr;<br class="">+    if (auto FI = dyn_cast<FPMathOperator>(&I))<br class="">+      SimpleV =<br class="">+          SimplifyFPBinOp(I.getOpcode(), LHS, RHS,<br class="">FI->getFastMathFlags());<br class="">+    else<br class="">+      SimpleV = SimplifyBinOp(I.getOpcode(), LHS, RHS);<br class=""><br class="">   if (SimpleV && CountedInsns.insert(&I).second)<br class="">     NumberOfOptimizedInstructions += TTI.getUserCost(&I);<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=""></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=""><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><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="">llvm-commits mailing list</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=""><a href="mailto:llvm-commits@cs.uiuc.edu" 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="">llvm-commits@cs.uiuc.edu</a><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=""><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" 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="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></div></blockquote></div><br class=""></div></body></html>