nir/loop_analyze: Don't test non-positive iterations count
Testing negative iterations count makes no sense, and can cause issues when the unsigned type is used. Testing 0 iterations is already covered with will_break_on_first_iteration, so it can be skipped too. Fixes:6772a17a
("nir: Add a loop analysis pass") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9913 Signed-off-by: Sviatoslav Peleshko <sviatoslav.peleshko@globallogic.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26173> (cherry picked from commita6459e0f7b
)
This commit is contained in:

committed by
Eric Engestrom

parent
ab4a2e97a9
commit
e17dfc075a
@@ -204,7 +204,7 @@
|
|||||||
"description": "nir/loop_analyze: Don't test non-positive iterations count",
|
"description": "nir/loop_analyze: Don't test non-positive iterations count",
|
||||||
"nominated": true,
|
"nominated": true,
|
||||||
"nomination_type": 1,
|
"nomination_type": 1,
|
||||||
"resolution": 0,
|
"resolution": 1,
|
||||||
"main_sha": null,
|
"main_sha": null,
|
||||||
"because_sha": "6772a17acc8ee90f9398348251a4455f988208fd",
|
"because_sha": "6772a17acc8ee90f9398348251a4455f988208fd",
|
||||||
"notes": null
|
"notes": null
|
||||||
|
@@ -1138,11 +1138,13 @@ calculate_iterations(nir_def *basis, nir_def *limit_basis,
|
|||||||
*/
|
*/
|
||||||
for (int bias = -1; bias <= 1; bias++) {
|
for (int bias = -1; bias <= 1; bias++) {
|
||||||
const int iter_bias = iter_int + bias;
|
const int iter_bias = iter_int + bias;
|
||||||
|
if (iter_bias < 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (test_iterations(iter_bias, step, limit, alu_op, bit_size,
|
if (test_iterations(iter_bias, step, limit, alu_op, bit_size,
|
||||||
induction_base_type, initial,
|
induction_base_type, initial,
|
||||||
limit_rhs, invert_cond, execution_mode)) {
|
limit_rhs, invert_cond, execution_mode)) {
|
||||||
return iter_bias > 0 ? iter_bias - trip_offset : iter_bias;
|
return iter_bias - trip_offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -285,6 +285,7 @@ COMPARE_REVERSE(ishl)
|
|||||||
|
|
||||||
INOT_COMPARE(ilt_rev)
|
INOT_COMPARE(ilt_rev)
|
||||||
INOT_COMPARE(ine)
|
INOT_COMPARE(ine)
|
||||||
|
INOT_COMPARE(uge_rev)
|
||||||
|
|
||||||
#define KNOWN_COUNT_TEST(_init_value, _cond_value, _incr_value, cond, incr, count) \
|
#define KNOWN_COUNT_TEST(_init_value, _cond_value, _incr_value, cond, incr, count) \
|
||||||
TEST_F(nir_loop_analyze_test, incr ## _ ## cond ## _known_count_ ## count) \
|
TEST_F(nir_loop_analyze_test, incr ## _ ## cond ## _known_count_ ## count) \
|
||||||
@@ -567,6 +568,16 @@ KNOWN_COUNT_TEST_INVERT(0x00000000, 0x00000001, 0x00000006, ige, iadd, 5)
|
|||||||
*/
|
*/
|
||||||
KNOWN_COUNT_TEST(0x0000000a, 0x00000005, 0xffffffff, inot_ilt_rev, iadd, 5)
|
KNOWN_COUNT_TEST(0x0000000a, 0x00000005, 0xffffffff, inot_ilt_rev, iadd, 5)
|
||||||
|
|
||||||
|
/* uint i = 0;
|
||||||
|
* while (true) {
|
||||||
|
* if (!(0 >= i))
|
||||||
|
* break;
|
||||||
|
*
|
||||||
|
* i += 1;
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
KNOWN_COUNT_TEST(0x00000000, 0x00000000, 0x00000001, inot_uge_rev, iadd, 1)
|
||||||
|
|
||||||
/* uint i = 0;
|
/* uint i = 0;
|
||||||
* while (true) {
|
* while (true) {
|
||||||
* if (i != 0)
|
* if (i != 0)
|
||||||
|
Reference in New Issue
Block a user