On 8/24/26 10:14, Eric Botcazou wrote:
The first version, requiring INTEGER_CST low_bound.  But ...

                     && query->range_of_expr (vr, index)
                     && !vr.varying_p ()
-                   && !vr.undefined_p ())
+                   && !vr.undefined_p ()
+                   && (integer_zerop (low_bound)
+                       || query->range_of_expr
+                            (vr,
+                             build2 (MINUS_EXPR, TREE_TYPE (index),
+                                     index, low_bound))))

can you try to use

   range_op_handler op (MINUS_EXPR);

   || !op.fold_range (vr, TREE_TYPE (index), vr, low_bound_range)

with building a constant range for low_bound (not exactly sure how to
best do that)?  I think you'll also need to repeat the
!vr.varying_p () / !vr.undefined_p () checks -- possibly they
could be simply delayed and feeding fold_range with those could
be OK.
The attached version seems to do the job:


Yeah,    query->range_of_expr (vr_lb, low_bound) would be the generally accepted way to generate a range from an arbitrary tree...  including a constant.

Andrew

Reply via email to