[PATCH] Optimize a >= 0 && a < b if VR info says b >= 0 (PR tree-optimization/77664)

Marc Glisse marc.glisse@inria.fr
Thu Oct 6 21:55:00 GMT 2016


On Thu, 6 Oct 2016, Jakub Jelinek wrote:

> For signed a, if we see a >= 0 && a < b and from VR know that b >= 0,
> we can optimize those 2 comparisons into one unsigned -
> (unsigned) a < (unsigned) b.  Similarly for a < 0 || a > b (and also
> for a <= b in the first and a >= b in the second).

I guess that the slightly more general:
X >= A && X < B where we know that A <= B
--> (unsigned)X - (unsigned)A < (unsigned)B - (unsigned)A

generates too many operations and does not gain anything? The case where A 
and B are constants seems to be handled by ifcombine, currently.

-- 
Marc Glisse



More information about the Gcc-patches mailing list