<div dir="ltr">Hi Chad,<div><br></div><div>On cortex-a57, we found a 3.8% performance regression on 429.mcf in spec2006 due to this commit, would you have a look of this?</div><div><br></div><div>The branch order changed by this commit.</div><div><br></div><div>Before:</div><div><div>  tbz<span class="" style="white-space:pre">      </span>x8, #63, 4028e0 <primal_bea_mpp+0x250></div><div>  cmp<span class="" style="white-space:pre"> </span>w12, #0x1</div><div>  b.eq<span class="" style="white-space:pre">   </span>4028ec <primal_bea_mpp+0x25c></div></div><div><br></div><div><br></div><div>After:</div><div><div>  cmp<span class="" style="white-space:pre">   </span>w12, #0x1</div><div>  <a href="http://b.ne">b.ne</a><span class="" style="white-space:pre">  </span>40290c <primal_bea_mpp+0x250></div><div>  tbnz<span class="" style="white-space:pre">        </span>x8, #63, 402918 <primal_bea_mpp+0x25c></div></div><div><br></div><div>This change happens in function primal_bea_mpp and got performance worse.</div><div><br></div><div>I didn't look into detail, that's all what I know from a simple investigation. Hopefully this can give you a clue to fix it.</div><div><br></div><div>Thanks,</div><div>Kevin  </div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-14 17:09 GMT+00:00 Chad Rosier <span dir="ltr"><<a href="mailto:mcrosier@codeaurora.org" target="_blank">mcrosier@codeaurora.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: mcrosier<br>
Date: Fri Nov 14 11:09:19 2014<br>
New Revision: 222008<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=222008&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=222008&view=rev</a><br>
Log:<br>
[Reassociate] Canonicalize the operands of all binary operators.<br>
<br>
Added:<br>
    llvm/trunk/test/Transforms/Reassociate/commute.ll<br>
Modified:<br>
    llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp<br>
    llvm/trunk/test/Transforms/Reassociate/multistep.ll<br>
<br>
Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=222008&r1=222007&r2=222008&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=222008&r1=222007&r2=222008&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Fri Nov 14 11:09:19 2014<br>
@@ -2078,19 +2078,19 @@ void Reassociate::OptimizeInst(Instructi<br>
   if (Instruction *Res = canonicalizeNegConstExpr(I))<br>
     I = Res;<br>
<br>
-  // Commute floating point binary operators, to canonicalize the order of their<br>
-  // operands.  This can potentially expose more CSE opportunities, and makes<br>
-  // writing other transformations simpler.<br>
-  if (I->getType()->isFloatingPointTy() || I->getType()->isVectorTy()) {<br>
+  // Commute binary operators, to canonicalize the order of their operands.<br>
+  // This can potentially expose more CSE opportunities, and makes writing other<br>
+  // transformations simpler.<br>
+  if (I->isCommutative())<br>
+    canonicalizeOperands(I);<br>
<br>
-    if (I->isCommutative())<br>
-      canonicalizeOperands(I);<br>
+  // Don't optimize vector instructions.<br>
+  if (I->getType()->isVectorTy())<br>
+    return;<br>
<br>
-    // Don't try to optimize vector instructions or anything that doesn't have<br>
-    // unsafe algebra.<br>
-    if (I->getType()->isVectorTy() || !I->hasUnsafeAlgebra())<br>
-      return;<br>
-  }<br>
+  // Don't optimize floating point instructions that don't have unsafe algebra.<br>
+  if (I->getType()->isFloatingPointTy() && !I->hasUnsafeAlgebra())<br>
+    return;<br>
<br>
   // Do not reassociate boolean (i1) expressions.  We want to preserve the<br>
   // original order of evaluation for short-circuited comparisons that<br>
<br>
Added: llvm/trunk/test/Transforms/Reassociate/commute.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Reassociate/commute.ll?rev=222008&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Reassociate/commute.ll?rev=222008&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/Reassociate/commute.ll (added)<br>
+++ llvm/trunk/test/Transforms/Reassociate/commute.ll Fri Nov 14 11:09:19 2014<br>
@@ -0,0 +1,19 @@<br>
+; RUN: opt -reassociate -S < %s | FileCheck %s<br>
+<br>
+declare void @use(i32)<br>
+<br>
+define void @test1(i32 %x, i32 %y) {<br>
+; CHECK-LABEL: test1<br>
+; CHECK: mul i32 %y, %x<br>
+; CHECK: mul i32 %y, %x<br>
+; CHECK: sub i32 %1, %2<br>
+; CHECK: call void @use(i32 %{{.*}})<br>
+; CHECK: call void @use(i32 %{{.*}})<br>
+<br>
+  %1 = mul i32 %x, %y<br>
+  %2 = mul i32 %y, %x<br>
+  %3 = sub i32 %1, %2<br>
+  call void @use(i32 %1)<br>
+  call void @use(i32 %3)<br>
+  ret void<br>
+}<br>
<br>
Modified: llvm/trunk/test/Transforms/Reassociate/multistep.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Reassociate/multistep.ll?rev=222008&r1=222007&r2=222008&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Reassociate/multistep.ll?rev=222008&r1=222007&r2=222008&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/Reassociate/multistep.ll (original)<br>
+++ llvm/trunk/test/Transforms/Reassociate/multistep.ll Fri Nov 14 11:09:19 2014<br>
@@ -9,7 +9,7 @@ define i64 @multistep1(i64 %a, i64 %b, i<br>
   %t3 = mul i64 %a, %t2 ; a*(a*c)<br>
   %t4 = add i64 %t1, %t3<br>
 ; CHECK-NEXT: add i64 %c, %b<br>
-; CHECK-NEXT: mul i64 %tmp{{.*}}, %a<br>
+; CHECK-NEXT: mul i64 %a, %tmp{{.*}}<br>
 ; CHECK-NEXT: mul i64 %tmp{{.*}}, %a<br>
 ; CHECK-NEXT: ret<br>
   ret i64 %t4<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Best Regards,<div><br></div><div>Kevin Qin</div></div></div>
</div>