Commit Graph

19 Commits

Author SHA1 Message Date
Max Kazantsev f10500e220 [IndVars] Use isLoopBackedgeGuardedByCond for last iteration check
Use more context to prove contextual facts about the last iteration. It is
only executed when the backedge is taken, so we can use `isLoopBackedgeGuardedByCond`
to make this check.

Differential Revision: https://reviews.llvm.org/D91535
Reviewed By: skatkov
2020-11-26 12:37:21 +07:00
Max Kazantsev f33118c61c [IndVars] Support different types of ExitCount when optimizing exit conds
In some cases we can handle IV and iter count of different types. It's a typical situation
after IV have been widened. This patch adds support for such cases, when legal.

Differential Revision: https://reviews.llvm.org/D88528
Reviewed By: skatkov
2020-11-18 18:20:05 +07:00
Max Kazantsev 58f9ceaad6 [Test] More tests on range checks 2020-11-16 20:10:10 +07:00
Max Kazantsev b2fd9ff579 [Test] More tests on range check elimination 2020-11-16 19:18:25 +07:00
Max Kazantsev b4ac9a158e [Test] One more IndVars test with inverted exit condition 2020-11-13 16:02:31 +07:00
Max Kazantsev 9224d322a2 [IndVars] Fix branches exiting by true with invariant conditions
Forgot to invert the condition for them.
2020-11-13 15:52:00 +07:00
Max Kazantsev e36d101fdb [Test] Add test with inverted branch 2020-11-13 15:51:59 +07:00
Max Kazantsev 77efb73c67 [IndVars] Replace checks with invariants if we cannot remove them
If we cannot prove that the check is trivially true, but can prove that it either
fails on the 1st iteration or never fails, we can replace it with first iteration check.

Differential Revision: https://reviews.llvm.org/D88527
Reviewed By: skatkov
2020-11-13 12:23:12 +07:00
Max Kazantsev f847094c24 [IndVars] Use knowledge about execution on last iteration when removing checks
If we know that some check will not be executed on the last iteration, we can use this
fact to eliminate its check.

Differential Revision: https://reviews.llvm.org/D88210
Reviwed By: ebrevnov
2020-11-03 13:38:58 +07:00
Max Kazantsev 160a453138 Return "[IndVars] Remove monotonic checks with unknown exit count"
This reverts commit e038b60d91.
This reverts commit a0d84d8031.

This revert was a mistake. The reason of the failures was
"Use uint64_t for branch weights instead of uint32_t"

Differential Revision: https://reviews.llvm.org/D87832
2020-10-28 18:51:40 +07:00
Raphael Isemann e038b60d91 Revert "[IndVars] Remove monotonic checks with unknown exit count"
This reverts commit c6ca26c0bf.
This breaks stage2 builds due to hitting this assert:
```
   Assertion failed: (WeightSum <= UINT32_MAX && "Expected weights to scale down to 32 bits"), function calcMetadataWeights
```
when compiling AArch64RegisterBankInfo.cpp in LLVM.
2020-10-27 15:31:37 +01:00
Max Kazantsev 6335446c99 [Test] One more range check test 2020-10-27 14:51:36 +07:00
Max Kazantsev c6ca26c0bf [IndVars] Remove monotonic checks with unknown exit count
Even if the exact exit count is unknown, we can still prove that this
exit will not be taken. If we can prove that the predicate is monotonic,
fulfilled on first & last iteration, and no overflow happened in between,
then the check can be removed.

Differential Revision: https://reviews.llvm.org/D87832
Reviewed By: apilipenko
2020-10-27 11:35:16 +07:00
Max Kazantsev 15985952ac [Test] Add tests where we can replace condition with invariants 2020-09-28 12:04:20 +07:00
Max Kazantsev 6985135a43 [Test] Add positive range checks tests in addition to negative 2020-09-16 14:24:42 +07:00
Max Kazantsev 94f7d3dba3 [Test] Some more potential range check elimination opportunities 2020-09-16 14:00:19 +07:00
Max Kazantsev 8a04cdb510 [Test] Add signed version of a test 2020-09-16 11:30:21 +07:00
Max Kazantsev 8a3907cd49 [Test] Simplify test by removing unneeded variable 2020-09-02 18:39:43 +07:00
Max Kazantsev e7f53044e7 [Test] Move IndVars test to a proper place 2020-09-01 12:17:31 +07:00