[PATCH] D48828: [InstSimplify] fold extracting from std::pair

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 18 10:15:13 PDT 2018


lebedev.ri added a comment.

In https://reviews.llvm.org/D48828#1164928, @inouehrs wrote:

> In https://reviews.llvm.org/D48828#1163506, @spatel wrote:
>
> > All of the tests for instsimplify are already folded if you run -instcombine. Could the motivating problem also be considered a pass ordering bug?
>
>
> @spatel 
>  The simplified test cases can be optimized by current instcombine pass.


I do agree that it it concerning that instcombine already handles this.
However this pattern really looks like something for instsimplify.

So i guess my question is, what in instcombine does this fold?
Is it very general, and this is only one of the cases it handles?
If not, maybe it should be refactored into instsimplify.

In https://reviews.llvm.org/D48828#1164928, @inouehrs wrote:

> But to enable jump threading for std::pair, which is the original motivation of the patch,
>  we must apply this folding over a phi node as discussed in https://reviews.llvm.org/D44626.


Can you explain that in layman terms?
I don't see anything phi-related in instsimplify changes.

> Executing jump threading pass again after CFG simplification may catch this opportunity. But I think it is better to do jump threading early to help other optimizers.



================
Comment at: lib/Analysis/InstructionSimplify.cpp:1814
+  // from X and Y are disjoint in (X << A) | Y.
+  // ((X << A) | Y) & 1 -> Y  if effective width of Y is 1 (i.e. boolean).
+  // ((X << A) | Y) & (1 << A) -> X << A  if effective width of X is 1.
----------------
I do not understand.
Why is this only handling the case where `Y` is `bool`?



https://reviews.llvm.org/D48828





More information about the llvm-commits mailing list