nir/loop_analyze: Fix get_iteration for ine and fneu
I discovered this problem because adding an algebraic transformation to convert some uge
and ult
to ieq
or ine
caused a couple loops to stop unrolling. Consider the loop:
uint i = 0;
while (true) {
if (i >= 1)
break;
i++;
}
This loop clearly executes exactly one time. Note that uge(x, 1)
is equivalent to ine(x, 0)
. Changing the condition to if (i != 0)
will also execute exactly one time.
In the added test cases, uge_once
correctly get an exact loop trip count of 1. Without the changes to nir_loop_analyze.c, the ine_once
case detects a maximum loop trip count of zero and does not get an exact loop trip count.
No changes in shader-db or fossil-db.
Fixes: 6772a17a ("nir: Add a loop analysis pass")