[LoopFlatten] Fix IV increment use count
authorDavid Green <david.green@arm.com>
Tue, 22 Nov 2022 07:23:56 +0000 (07:23 +0000)
committerDavid Green <david.green@arm.com>
Tue, 22 Nov 2022 07:23:56 +0000 (07:23 +0000)
commit8e9e22f07bcbe2ee95478684cf31948370e4e51e
tree1b4316cc30b513fa001fcaff991742c47f785902
parent2d4b998697fda9a0a213e5fb29f8af45a4828dc7
[LoopFlatten] Fix IV increment use count

The add from the IV in the inner loop was always checking for 2 uses,
the phi and the compare. The compare could be based on the phi though,
leaving one valid use of the compare. In the testcase we could be left
with the phi and a lcssa phi as the two users, invalidly allowing
flattening where we shouldn't.

Fixes 58441

Differential Revision: https://reviews.llvm.org/D138404
llvm/lib/Transforms/Scalar/LoopFlatten.cpp
llvm/test/Transforms/LoopFlatten/widen-pr58441.ll