nir/loop_analyze: Fix inverted condition handling in iterations calculation

In the tagged commit, we stopped actually inverting the condition, and
instead relied on the "invert_cond" flag. But we missed a few places
where this flag should've been handled too.

Also, add a few more tests to make sure this won't regress in the future.

Fixes: 99a7a664 ("nir/loop_analyze: Change invert_cond instead of changing the condition")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10012
Signed-off-by: Sviatoslav Peleshko <sviatoslav.peleshko@globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26024>
This commit is contained in:
Sviatoslav Peleshko
2023-11-03 03:13:50 +02:00
committed by Marge Bot
parent 385b81c8c2
commit aa33ca0a52
2 changed files with 79 additions and 5 deletions
@@ -284,6 +284,7 @@ COMPARE_REVERSE(ishl)
}
INOT_COMPARE(ilt_rev)
INOT_COMPARE(ine)
#define KNOWN_COUNT_TEST(_init_value, _cond_value, _incr_value, cond, incr, count) \
TEST_F(nir_loop_analyze_test, incr ## _ ## cond ## _known_count_ ## count) \
@@ -476,6 +477,26 @@ KNOWN_COUNT_TEST(0x00000000, 0x00000001, 0x00000001, uge, iadd, 1)
*/
KNOWN_COUNT_TEST(0x00000000, 0x00000000, 0x00000001, ine, iadd, 1)
/* uint i = 0;
* while (true) {
* if (!(i != 6))
* break;
*
* i++;
* }
*/
KNOWN_COUNT_TEST(0x00000000, 0x00000006, 0x00000001, inot_ine, iadd, 6)
/* uint i = 0;
* while (true) {
* i++;
*
* if (!(i != 8))
* break;
* }
*/
KNOWN_COUNT_TEST_INVERT(0x00000000, 0x00000001, 0x00000008, inot_ine, iadd, 7)
/* uint i = 0;
* while (true) {
* if (i == 1)
@@ -486,6 +507,26 @@ KNOWN_COUNT_TEST(0x00000000, 0x00000000, 0x00000001, ine, iadd, 1)
*/
KNOWN_COUNT_TEST(0x00000000, 0x00000001, 0x00000001, ieq, iadd, 1)
/* uint i = 0;
* while (true) {
* if (i == 6)
* break;
*
* i++;
* }
*/
KNOWN_COUNT_TEST(0x00000000, 0x00000006, 0x00000001, ieq, iadd, 6)
/* uint i = 0;
* while (true) {
* i++;
*
* if (i == 6)
* break;
* }
*/
KNOWN_COUNT_TEST_INVERT(0x00000000, 0x00000001, 0x00000006, ieq, iadd, 5)
/* float i = 0.0;
* while (true) {
* if (i != 0.0)