<div dir="ltr"><div><br></div>Hi David,<div><br></div><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">clang-</span><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">format-diff.py it is. </span></div>

<div><br></div><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">Sample usage as mentioned in the file:</span></div>

<div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></span></div><div><div><font face="Arial, Helvetica, sans-serif">git diff -U0 HEAD^ | clang-format-diff.py -i -p1</font></div></div><div><br></div>

<div>svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i</div><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">Thanks for pointing out! Will be helpful.</span></div>

<div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></span></div><div>Rahul</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, May 31, 2014 at 9:13 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Sat, May 31, 2014 at 8:02 AM, Rahul Jain <<a href="mailto:rahul1.jain@samsung.com">rahul1.jain@samsung.com</a>> wrote:<br>


><br>
> Hi Benjamin,<br>
><br>
> Thanks for the review.<br>
> No I dont have commit access as of now, would be helpful if<br>
> you could commit it for me. Will request for one soon!<br>
><br>
> Updated patch removing the whitespace-only changes, those were<br>
> introduced on running clang-format.<br>
<br>
</div>There's a script for running clang-format over a diff (or over a git<br>
revision range) that should help cleanup your work without introducing<br>
unrelated changes (I forget the exact name, it's somewhere in the<br>
clang-format project directory)<br>
<div class="HOEnZb"><div class="h5"><br>
> Also patched to an updated revision.<br>
><br>
> Please commit it on my behalf.<br>
><br>
> Thanks again for the help!<br>
> Rahul<br>
><br>
> <a href="http://reviews.llvm.org/D3835" target="_blank">http://reviews.llvm.org/D3835</a><br>
><br>
> Files:<br>
>   lib/Transforms/Scalar/Reassociate.cpp<br>
>   test/Transforms/Reassociate/inverses.ll<br>
><br>
> Index: lib/Transforms/Scalar/Reassociate.cpp<br>
> ===================================================================<br>
> --- lib/Transforms/Scalar/Reassociate.cpp<br>
> +++ lib/Transforms/Scalar/Reassociate.cpp<br>
> @@ -1368,11 +1368,10 @@<br>
>  Value *Reassociate::OptimizeAdd(Instruction *I,<br>
>                                  SmallVectorImpl<ValueEntry> &Ops) {<br>
>    // Scan the operand lists looking for X and -X pairs.  If we find any, we<br>
> -  // can simplify the expression. X+-X == 0.  While we're at it, scan for any<br>
> +  // can simplify expressions like X+-X == 0 and X+~X ==-1.  While we're at it,<br>
> +  // scan for any<br>
>    // duplicates.  We want to canonicalize Y+Y+Y+Z -> 3*Y+Z.<br>
> -  //<br>
> -  // TODO: We could handle "X + ~X" -> "-1" if we wanted, since "-X = ~X+1".<br>
> -  //<br>
> +<br>
>    for (unsigned i = 0, e = Ops.size(); i != e; ++i) {<br>
>      Value *TheOp = Ops[i].Op;<br>
>      // Check to see if we've seen this operand before.  If so, we factor all<br>
> @@ -1412,19 +1411,28 @@<br>
>        continue;<br>
>      }<br>
><br>
> -    // Check for X and -X in the operand list.<br>
> -    if (!BinaryOperator::isNeg(TheOp))<br>
> +    // Check for X and -X or X and ~X in the operand list.<br>
> +    if (!BinaryOperator::isNeg(TheOp) && !BinaryOperator::isNot(TheOp))<br>
>        continue;<br>
><br>
> -    Value *X = BinaryOperator::getNegArgument(TheOp);<br>
> +    Value *X = nullptr;<br>
> +    if (BinaryOperator::isNeg(TheOp))<br>
> +      X = BinaryOperator::getNegArgument(TheOp);<br>
> +    else if (BinaryOperator::isNot(TheOp))<br>
> +      X = BinaryOperator::getNotArgument(TheOp);<br>
> +<br>
>      unsigned FoundX = FindInOperandList(Ops, i, X);<br>
>      if (FoundX == i)<br>
>        continue;<br>
><br>
>      // Remove X and -X from the operand list.<br>
> -    if (Ops.size() == 2)<br>
> +    if (Ops.size() == 2 && BinaryOperator::isNeg(TheOp))<br>
>        return Constant::getNullValue(X->getType());<br>
><br>
> +    // Remove X and ~X from the operand list.<br>
> +    if (Ops.size() == 2 && BinaryOperator::isNot(TheOp))<br>
> +      return Constant::getAllOnesValue(X->getType());<br>
> +<br>
>      Ops.erase(Ops.begin()+i);<br>
>      if (i < FoundX)<br>
>        --FoundX;<br>
> @@ -1434,6 +1442,13 @@<br>
>      ++NumAnnihil;<br>
>      --i;     // Revisit element.<br>
>      e -= 2;  // Removed two elements.<br>
> +<br>
> +    // if X and ~X we append -1 to the operand list.<br>
> +    if (BinaryOperator::isNot(TheOp)) {<br>
> +      Value *V = Constant::getAllOnesValue(X->getType());<br>
> +      Ops.insert(Ops.end(), ValueEntry(getRank(V), V));<br>
> +      e += 1;<br>
> +    }<br>
>    }<br>
><br>
>    // Scan the operand list, checking to see if there are any common factors<br>
> Index: test/Transforms/Reassociate/inverses.ll<br>
> ===================================================================<br>
> --- test/Transforms/Reassociate/inverses.ll<br>
> +++ test/Transforms/Reassociate/inverses.ll<br>
> @@ -32,3 +32,15 @@<br>
>  ; CHECK: %tmp.5 = add i32 %b, 1234<br>
>  ; CHECK: ret i32 %tmp.5<br>
>  }<br>
> +<br>
> +define i32 @test4(i32 %b, i32 %a) {<br>
> +        %tmp.1 = add i32 %a, 1234<br>
> +        %tmp.2 = add i32 %b, %tmp.1<br>
> +        %tmp.4 = xor i32 %a, -1<br>
> +        ; (b+(a+1234))+~a -> b+1233<br>
> +        %tmp.5 = add i32 %tmp.2, %tmp.4<br>
> +        ret i32 %tmp.5<br>
> +; CHECK-LABEL: @test4(<br>
> +; CHECK: %tmp.5 = add i32 %b, 1233<br>
> +; CHECK: ret i32 %tmp.5<br>
> +}<br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> _______________________________________________<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>
><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>
</div></div></blockquote></div><br></div>