[InstCombine] limit icmp fold with sub if other sub user is a phi
authorSanjay Patel <spatel@rotateright.com>
Sat, 2 Apr 2022 23:23:42 +0000 (19:23 -0400)
committerSanjay Patel <spatel@rotateright.com>
Sat, 2 Apr 2022 23:23:42 +0000 (19:23 -0400)
commit5f8c2b884d4288617138114ebd2fdb235452c8ce
tree69569aa20e88f8f77ac5f7d99596ea233e317076
parent97ac0cd6c4e015d89af3db164d6c43fbc6c5ca57
[InstCombine] limit icmp fold with sub if other sub user is a phi

This is a hacky fix for:
https://github.com/llvm/llvm-project/issues/54558

As discussed there, codegen regressed when we opened up this transform
to allow extra uses ( 61580d0949fd3465 ), and it's not clear how to
undo the transforms at the later stage of compilation.

As noted in the code comments, there's a set of remaining folds that
are still limited to one-use, so we can try harder to refine and
expand the limitations on these folds, but it's likely to be an
up-and-down battle as we find and overcome similar regressions.

Differential Revision: https://reviews.llvm.org/D122909
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-sub.ll