[PATCH] D21315: Reorder SimplifyCFG and SROA?

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 14 11:06:03 PDT 2016

chandlerc added a comment.

In http://reviews.llvm.org/D21315#457672, @tjablin wrote:

> Hi Chandler,
>  The FoldValueComparisonIntoPredecessors logic already mostly understands the code pattern produced by FoldingBranchToCommonDest, but would need to duplicate most of the logic from Early-CSE to get the rest of the way there. The current pass order is: CFGSimplification, SROA, EarlyCSE. If either EarlyCSE or SROA runs before SimplifyCFG there's no problem. Alternatively, a second pass through SimplifyCFG will also generate good code as long as it is before InstCombine. InstCombine is problematic since it "strength reduces" some equality comparisons to bitwise operations. For example:
>   (i == 5334 || i == 5335)
> becomes
>   ((i | 1) == 5335)

If this is how the equality expression is canonicalized by instcombine, then this is how simplify-cfg needs to match it.

If there is logic elsewhere that should be commonly factored out to help build the equality set out of this reduced form, we should extract it and use it in both places.

If this simply cannot be reasonably matched afterward, then instcombine is destroying information rather than canonicalizing, and we should teach it to use a different canonical form in order to make matching on these patterns easier.


More information about the llvm-commits mailing list