[LoopFlatten] Bail if we can't perform flattening after IV widening
authorSjoerd Meijer <sjoerd.meijer@arm.com>
Wed, 29 Sep 2021 18:32:46 +0000 (19:32 +0100)
committerSjoerd Meijer <sjoerd.meijer@arm.com>
Wed, 29 Sep 2021 18:53:34 +0000 (19:53 +0100)
commit367df18050303b27bc6937e44e4d636332333ae7
tree45efef59ca6fc5c8bafa852317d2c55ed9821d52
parent2d42a192e02af9d89dde356a48270fc7d1ef5b16
[LoopFlatten] Bail if we can't perform flattening after IV widening

It can happen that after widening of the IV, flattening may not be possible,
e.g. when it is deemed unprofitable. We were not properly checking this, which
resulted in flattening being applied when it shouldn't, also leading to
incorrect results (miscompilation).

This should fix PR51980 (https://bugs.llvm.org/show_bug.cgi?id=51980)

Differential Revision: https://reviews.llvm.org/D110712
llvm/lib/Transforms/Scalar/LoopFlatten.cpp
llvm/test/Transforms/LoopFlatten/widen-iv3.ll [new file with mode: 0644]