On 8/25/26 6:39 AM, Richard Biener wrote:
On Mon, Aug 24, 2026 at 9:01 PM Eric Botcazou <[email protected]> wrote:
My slight preference would be to just do the math and simply check at
the end.. Fold will work fine on all those values (in fact
UNDEFINED gets translated to VARYING I believe). so I don't see the
point in multiple checks. .. yeah, slightly more work I suppose.. But it
eliminates any possibility that operator_minus does something unexpected.
Understood, here's the version I'm going to test. For the record, the special
casing of a zero low bound is necessary, because if you do just:
&& query->range_of_expr (vr_idx, index)
&& query->range_of_expr (vr_lb, low_bound)
&& minus_op.fold_range (vr, TREE_TYPE (index),
vr_idx, vr_lb)
&& !vr.varying_p ()
&& !vr.undefined_p ())
you get a checking failure about type consistency in the ranger for almost all
C tests involving arrays. But that's expected: you get an equivalent checking
failure if you do the same operation on trees:
index = fold_build2 (MINUS_EXPR, TREE_TYPE (index),
index, low_bound);
because the C FE does not guarantee type consistency of its fixed zero low
bound with the index expression (unlike FEs for languages supporting arbitrary
low bounds like Ada, which otherwise would break the middle-end).
LGTM. Please leave Andrew a window in his timezone to have a look as well.
Thanks,
Richard.
Fine by me too.
Andrew