[InstCombine] Prevent InstCombine from triggering an extra iteration if something...
authorCraig Topper <craig.topper@gmail.com>
Sat, 13 May 2017 06:56:04 +0000 (06:56 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sat, 13 May 2017 06:56:04 +0000 (06:56 +0000)
commit935f7b050fc38bdc55f50dc05039f5d2deac43b9
tree95c45e4ce73f5ac4f44b1d319711243b1554ab6e
parentc57477b2bde54b1a43b7f6bea502641d0264a646
[InstCombine] Prevent InstCombine from triggering an extra iteration if something changed in the initial Worklist creation

Summary:
If the Worklist build causes an IR change this change flag currently factors into the flag for running another iteration of the iteration loop. But only changes during processing should trigger another loop.

This patch captures the worklist creation change flag into the outside the loop flag currently used for DbgDeclares and only sends that flag up to the caller. Rerunning the loop only depends on IC.run() now.

This uses the debug output of InstCombine to determine if one or two iterations run. I couldn't think of a better way to detect it since the second spurious iteration shoudn't make any visible changes. Just wasted computation.

I can do a pre-commit of the test case with the CHECK-NOT as a CHECK if this is an ok way to check this.

This is a subset of D31678 as I'm still not sure how to verify the analysis behavior for that.

Reviewers: davide, majnemer, spatel, chandlerc

Reviewed By: davide

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D32453

llvm-svn: 302982
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/constant-fold-iteration.ll [new file with mode: 0644]