[PATCH] Passing down BinaryOperator flags to BinarySDNode + X86 optimization

Marcello Maggioni hayarms at gmail.com
Fri May 30 07:30:49 PDT 2014


Hmm, I think I run clang-format only on the part that I changed (moving the
Constant folding part of getNode into the separate static function) ,
because what I did was:

- Writing the FoldBinaryArithmetic function and modify the SelectionDAG
file for the patch.
- Run clang-format on top of all the SelectionDAG.cpp file
- Realizing this wasn't a good idea (:P)
- Starting back from a clean SelectionDAG.cpp file and integrating only the
changes ( I simply copied the clang-formatted changes I made into the clean
SelectionDAG.cpp).

Is it better to have two patches, one with the not clang-formatted
FoldBinaryArithmetic and one with the clang-formatted version you think?

Marcello


2014-05-29 23:07 GMT-07:00 Owen Anderson <resistor at mac.com>:

> Hi Marcello,
>
> I haven’t looked at the code changes, but it appears that you accidentally
> ran clang-format over all of SelectionDAG.cpp as part of flag_nodes.patch.
>  Please separate your intended diff out from that.
>
> —Owen
>
> On May 29, 2014, at 7:44 PM, Marcello Maggioni <hayarms at gmail.com> wrote:
>
> Hello,
>
> here is a proposed patch to pass down the BinaryOperator's
> "NoUnsignedWrap/NoSignedWrap and IsExact" flags down to the SDNodes so that
> backends can use them for additional optimizations.
>
> The core of the patch is using the SubclassData field of SDNode for
> BinarySDNodes to store the flags information.
> SelectionDAGBuilder will then set the correct flag information the moment
> the Binary instruction is visited during construction.
>
> In doing this I also refactored a little bit the getNode() method
> accepting two operands, extracting the main constant folding logic into a
> separate static function.
>
> The patch implementing this is the file "flag_nodes.patch" attached.
>
> In addition I implemented an optimization where an unneeded "test
> instruction" that was emitted from the X86 backend is not emitted anymore.
> This optimization uses this new feature.
>
> This optimization is contained in the "x86_opt_wrap.patch" attached.
>
> I also added a test case that exercises the optimization in the
> "factorial_test.patch"
>
> The patch makes this snippet of code:
>
> LBB0_1:                                 ## %while.body
>                                                ## =>This Inner Loop
> Header: Depth=1
>          imulq   %rdi, %rax
>          decq    %rdi
>          testq    %rdi, %rdi
>          jg      LBB0_1
>
>
>
> become this:
>
>
>
> LBB0_1:                                 ## %while.body
>                                                ## =>This Inner Loop
> Header: Depth=1
>          imulq   %rdi, %rax
>          decq    %rdi
>          jg      LBB0_1
>
> if the NSW flag is set on the SDNode that represents the DEC instruction
> (presumably an ADD or a SUB node in this case).
>
> If somebody could review this it would be awesome :)
>
> Cheers,
> Marcello
> <factorial_test.patch><flag_nodes.patch><x86_opt_wrap.patch>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140530/d1775943/attachment.html>


More information about the llvm-commits mailing list