<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Bruno,<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 6, 2015, at 12:21 PM, Bruno Cardoso Lopes <<a href="mailto:bruno.cardoso@gmail.com" class="">bruno.cardoso@gmail.com</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="">Hi,</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="">On Wed, Jul 1, 2015 at 8:12 PM, Quentin Colombet <</span><a href="mailto:qcolombet@apple.com" 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="">qcolombet@apple.com</a><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="">> wrote:</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="">Author: qcolombet<br class="">Date: Wed Jul  1 18:12:13 2015<br class="">New Revision: 241206<br class=""><br class="">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D241206-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=18sbrJ1cMANIgm0mhhgHN4cIovERsBZC1670VOPqV-M&s=n-zrBpegivoYD_FCAMLq2F7WbaWFGINZo1iiKQkvtKc&e=" class="">http://llvm.org/viewvc/llvm-project?rev=241206&view=rev</a><br class="">Log:<br class="">[TwoAddressInstructionPass] Try 3 Addr Conversion After Commuting.<br class=""><br class="">TwoAddressInstructionPass stops after a successful commuting but 3 Addr<br class="">conversion might be good for some cases.<br class=""><br class="">Consider:<br class=""><br class="">int foo(int a, int b) {<br class=""> return a + b;<br class="">}<br class=""><br class="">Before this commit, we emit:<br class=""><br class="">addl    %esi, %edi<br class="">movl    %edi, %eax<br class="">ret<br class=""><br class="">After this commit, we try 3 Addr conversion:<br class=""><br class="">leal    (%rsi,%rdi), %eax<br class="">ret<br class=""><br class="">Patch by Volkan Keles <<a href="mailto:vkeles@apple.com" class="">vkeles@apple.com</a>>!<br class=""><br class="">Differential Revision: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D10851&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=18sbrJ1cMANIgm0mhhgHN4cIovERsBZC1670VOPqV-M&s=nNlyhYGtj0KPFQM24JKvBjDDbT1QckzMnxPz8JViPIU&e=" class="">http://reviews.llvm.org/D10851</a><br class=""><br class="">Modified:<br class="">   llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp<br class="">   llvm/trunk/test/CodeGen/X86/commute-two-addr.ll<br class="">   llvm/trunk/test/CodeGen/X86/twoaddr-lea.ll<br class="">   llvm/trunk/test/CodeGen/X86/win64_params.ll<br class="">   llvm/trunk/test/Transforms/LoopStrengthReduce/X86/ivchain-stress-X86.ll<br class=""><br class="">Modified: llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp<br class="">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_TwoAddressInstructionPass.cpp-3Frev-3D241206-26r1-3D241205-26r2-3D241206-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=18sbrJ1cMANIgm0mhhgHN4cIovERsBZC1670VOPqV-M&s=MFIEyS55o0ULSegQYLEKsOs-knNuj1yfN25px_Tnkjo&e=" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp?rev=241206&r1=241205&r2=241206&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp (original)<br class="">+++ llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Wed Jul  1 18:12:13 2015<br class="">@@ -1207,12 +1207,24 @@ tryInstructionTransform(MachineBasicBloc<br class="">    }<br class="">  }<br class=""><br class="">+  // If the instruction is convertible to 3 Addr, instead<br class="">+  // of returning try 3 Addr transformation aggresively and<br class="">+  // use this variable to check later. Because it might be better.<br class="">+  // For example, we can just use `leal (%rsi,%rdi), %eax` and `ret`<br class="">+  // instead of the following code.<br class="">+  //   addl    %esi, %edi<br class="">+  //   movl    %edi, %eax<br class="">+  //   ret<br class="">+  bool commuted = false;<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="">Shouldn't we use "Commuted" instead of "commuted"? :-)</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><div><br class=""></div><div>You’re right. Good catch!</div><div><br class=""></div><div>Fixed in <span style="font-family: Menlo; font-size: 11px;" class="">Committed revision 241505.</span></div><div><br class=""></div>Cheers,</div><div>-Quentin<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=""><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="">  // If it's profitable to commute, try to do so.<br class="">  if (TryCommute && commuteInstruction(mi, regB, regC, Dist)) {<br class="">+    commuted = true;<br class="">    ++NumCommuted;<br class="">    if (AggressiveCommute)<br class="">      ++NumAggrCommuted;<br class="">-    return false;<br class="">+    if (!MI.isConvertibleTo3Addr())<br class="">+      return false;<br class="">  }<br class=""><br class="">  if (shouldOnlyCommute)<br class="">@@ -1220,7 +1232,7 @@ tryInstructionTransform(MachineBasicBloc<br class=""><br class="">  // If there is one more use of regB later in the same MBB, consider<br class="">  // re-schedule this MI below it.<br class="">-  if (EnableRescheduling && rescheduleMIBelowKill(mi, nmi, regB)) {<br class="">+  if (!commuted && EnableRescheduling && rescheduleMIBelowKill(mi, nmi, regB)) {<br class="">    ++NumReSchedDowns;<br class="">    return true;<br class="">  }<br class="">@@ -1237,6 +1249,10 @@ tryInstructionTransform(MachineBasicBloc<br class="">    }<br class="">  }<br class=""><br class="">+  // Return if it is commuted but 3 addr conversion is failed.<br class="">+  if (commuted)<br class="">+    return false;<br class="">+<br class="">  // If there is one more use of regB later in the same MBB, consider<br class="">  // re-schedule it before this MI if it's legal.<br class="">  if (EnableRescheduling && rescheduleKillAboveMI(mi, nmi, regB)) {<br class=""><br class="">Modified: llvm/trunk/test/CodeGen/X86/commute-two-addr.ll<br class="">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_CodeGen_X86_commute-2Dtwo-2Daddr.ll-3Frev-3D241206-26r1-3D241205-26r2-3D241206-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=18sbrJ1cMANIgm0mhhgHN4cIovERsBZC1670VOPqV-M&s=FfYfbmy3wuw0WUe1WGnv8KZenZg45S3pg055WIDAPE4&e=" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/commute-two-addr.ll?rev=241206&r1=241205&r2=241206&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/test/CodeGen/X86/commute-two-addr.ll (original)<br class="">+++ llvm/trunk/test/CodeGen/X86/commute-two-addr.ll Wed Jul  1 18:12:13 2015<br class="">@@ -39,7 +39,7 @@ define %0 @t3(i32 %lb, i8 zeroext %has_l<br class="">entry:<br class="">; DARWIN-LABEL: t3:<br class="">; DARWIN: shlq $32, %rcx<br class="">-; DARWIN-NEXT: orq %rcx, %rax<br class="">+; DARWIN-NEXT: leaq (%rax,%rcx), %rax<br class="">; DARWIN-NEXT: shll $8<br class="">; DARWIN-NOT: leaq<br class="">  %tmp21 = zext i32 %lb to i64<br class=""><br class="">Modified: llvm/trunk/test/CodeGen/X86/twoaddr-lea.ll<br class="">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_CodeGen_X86_twoaddr-2Dlea.ll-3Frev-3D241206-26r1-3D241205-26r2-3D241206-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=18sbrJ1cMANIgm0mhhgHN4cIovERsBZC1670VOPqV-M&s=Wi1b-mYXsLJZfQNPG5PRkztFD6xq2JyHP8bcjgeT88s&e=" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/twoaddr-lea.ll?rev=241206&r1=241205&r2=241206&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/test/CodeGen/X86/twoaddr-lea.ll (original)<br class="">+++ llvm/trunk/test/CodeGen/X86/twoaddr-lea.ll Wed Jul  1 18:12:13 2015<br class="">@@ -25,8 +25,7 @@ define i32 @test2(i32 inreg %a, i32 inre<br class="">entry:<br class="">; CHECK-LABEL: test2:<br class="">; CHECK: leal<br class="">-; CHECK-NOT: leal<br class="">-; CHECK-NOT: mov<br class="">+; CHECK-NEXT: addl<br class="">; CHECK-NEXT: addl<br class="">; CHECK-NEXT: ret<br class=""> %add = add i32 %b, %a<br class=""><br class="">Modified: llvm/trunk/test/CodeGen/X86/win64_params.ll<br class="">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_CodeGen_X86_win64-5Fparams.ll-3Frev-3D241206-26r1-3D241205-26r2-3D241206-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=18sbrJ1cMANIgm0mhhgHN4cIovERsBZC1670VOPqV-M&s=Ad75RSgzCjHz7EKfq2vnnRsZ6K8t9k1IWT2MFhI7sH8&e=" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/win64_params.ll?rev=241206&r1=241205&r2=241206&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/test/CodeGen/X86/win64_params.ll (original)<br class="">+++ llvm/trunk/test/CodeGen/X86/win64_params.ll Wed Jul  1 18:12:13 2015<br class="">@@ -7,8 +7,7 @@ define i32 @f6(i32 %p1, i32 %p2, i32 %p3<br class="">entry:<br class="">; CHECK: movl    48(%rsp), %eax<br class="">; CHECK: addl    40(%rsp), %eax<br class="">-; LINUX: addl    %r9d, %r8d<br class="">-; LINUX: movl    %r8d, %eax<br class="">+; LINUX: leal    (%r8,%r9), %eax<br class="">  %add = add nsw i32 %p6, %p5<br class="">  ret i32 %add<br class="">}<br class="">@@ -27,10 +26,8 @@ entry:<br class="">; on other platforms here (note the x86_64_sysvcc calling convention).<br class="">define x86_64_sysvcc i32 @f8(i32 %p1, i32 %p2, i32 %p3, i32 %p4, i32 %p5, i32 %p6) nounwind readnone optsize {<br class="">entry:<br class="">-; CHECK: addl    %r9d, %r8d<br class="">-; CHECK: movl    %r8d, %eax<br class="">-; LINUX: addl    %r9d, %r8d<br class="">-; LINUX: movl    %r8d, %eax<br class="">+; CHECK: leal    (%r8,%r9), %eax<br class="">+; LINUX: leal    (%r8,%r9), %eax<br class="">  %add = add nsw i32 %p6, %p5<br class="">  ret i32 %add<br class="">}<br class=""><br class="">Modified: llvm/trunk/test/Transforms/LoopStrengthReduce/X86/ivchain-stress-X86.ll<br class="">URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_Transforms_LoopStrengthReduce_X86_ivchain-2Dstress-2DX86.ll-3Frev-3D241206-26r1-3D241205-26r2-3D241206-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=18sbrJ1cMANIgm0mhhgHN4cIovERsBZC1670VOPqV-M&s=60cgOLiue_DrVzjpZXKzGW37svxvrBdk-ndWHM6gh4s&e=" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/X86/ivchain-stress-X86.ll?rev=241206&r1=241205&r2=241206&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/test/Transforms/LoopStrengthReduce/X86/ivchain-stress-X86.ll (original)<br class="">+++ llvm/trunk/test/Transforms/LoopStrengthReduce/X86/ivchain-stress-X86.ll Wed Jul  1 18:12:13 2015<br class="">@@ -23,7 +23,7 @@<br class="">; X32: add<br class="">; X32: add<br class="">; X32: add<br class="">-; X32: add<br class="">+; X32: leal<br class="">; X32: %for.body.3<br class="">define void @sharedidx(i8* nocapture %a, i8* nocapture %b, i8* nocapture %c, i32 %s, i32 %len) nounwind ssp {<br class="">entry:<br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@cs.uiuc.edu" class="">llvm-commits@cs.uiuc.edu</a><br class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<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=""><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="">Bruno Cardoso Lopes</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="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.brunocardoso.cc_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=18sbrJ1cMANIgm0mhhgHN4cIovERsBZC1670VOPqV-M&s=6S5JGVbzb57SRXpqphoTVTv2ryk-YgM-Y1i-pY4jKSE&e=" 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://www.brunocardoso.cc</a></div></blockquote></div><br class=""></div></body></html>