https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117875
--- Comment #6 from Andrew Macleod <amacleod at redhat dot com> --- (In reply to Richard Biener from comment #5) > I tried get_range_query (cfun)->range_of_expr (vr, niter->niter, stmt) with > (unsigned int) M_9(D) - (unsigned int) k_24 and an enabled ranger > but that indeed returns [irange] unsigned int [0, 1024][4294966273, +INF] > and not a singleton as expected. > It seems to look for ranges of M_9 and k_24 and fold_range with the > minus op rather than trying to use relations to simplify the subtraction. > The ranges of the first and 2nd op are [1, 1025] and [1, 1024] respectively, > basically [1, INF] for our purpose (the constant array bound bounds them). > > We'd also miss a way to inject niter->assumptions and niter->may_be_zero > as conditions known true for the purpose of simplifying (in this case > those don't add anything). It will always use ranges, and utilize any known relation in addition to that. range-op.cc : minus_op1_op2_relation_effect () is used for that purpose, but if can only adjust something to a known subrange, ie if m_9 > k_24, then it will limit whatever the calculated range is to [1, +INF], so we can trim out any negatives. What singleton are you expecting? (and where?) I hacked a VRP pass right after loop interchange and after the loop I see: =========== BB 16 ============ M_9(D) [irange] int [2, 1024] Relational : (k_12 >= M_9(D)) <bb 16> [local count: 67276368]: goto <bb 15>; [100.00%] but IM not sure how we use relations to come up with a singleton constant? The loop backedge has: =========== BB 8 ============ k_12 [irange] int [2, 1024] Relational : (M_9(D) > k_15) Relational : (k_12 < M_9(D)) <bb 8> [local count: 544326978]: goto <bb 3>; [100.00%] so we always know also M_9 > either k, 'mm just not sure how that helps OR are we talking about the second loop? Im having difficulty seeing where I might find a singleton?