https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108748
Bug ID: 108748 Summary: Enhancement: track ranges of poly_int indeterminates Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rsandifo at gcc dot gnu.org Target Milestone: --- I've no idea how this would work in practice, just recording it as an idea/TODO, but: it would be nice if code guarded by a range check on a poly_int could be optimised for the implied range of the indeterminates. Maybe ranger could be taught to do this. One simple example is: #include <arm_sve.h> uint64_t foo(uint64_t x) { if (svcntb() == 2) x += svcntb() * 100; return x; } which generates: cntb x1 cmp x1, 2 cntd x1, all, mul #3 lsl x1, x1, 8 add x1, x0, x1 incb x1, all, mul #4 csel x0, x1, x0, eq ret whereas the equivalent: #include <arm_sve.h> uint64_t foo(uint64_t x) { if (svcntb() == 2) x += 200; return x; } generates: cntb x1 cmp x1, 2 add x1, x0, 200 csel x0, x1, x0, eq ret A more realistic use case would be to guard a block of code with a particular VL in the hope that the code would be optimised for that VL.