[InstCombine] When swapping GEPs, only keep inbounds if both are
authorNikita Popov <npopov@redhat.com>
Mon, 30 May 2022 14:52:11 +0000 (16:52 +0200)
committerNikita Popov <npopov@redhat.com>
Mon, 30 May 2022 15:04:42 +0000 (17:04 +0200)
commita770f534e6f647d1f6a25544117e7b3d8a0c3486
tree8973ff9191e7311b3843bdd89c4a718ffadb4dde
parentd2e3cb737417a2e5ffad34f666fa8510e88e8bc2
[InstCombine] When swapping GEPs, only keep inbounds if both are

If only one of the GEPs is inbounds, then after swapping, there is
no guarantee that one of them will be inbounds as well
(see e.g. https://alive2.llvm.org/ce/z/agaCnp).

This is only a partial fix, because even if both are inbounds, the
result is not necessarily inbounds (if the offsets have different
signs).
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/gep-combine-loop-invariant.ll
llvm/test/Transforms/LoopVectorize/first-order-recurrence.ll