[PATCH v2] match.pd: Simplify unsigned A - B - 1 >= A to B >= A [PR94913]

Jeff Law law@redhat.com
Thu May 7 14:48:28 GMT 2020


On Thu, 2020-05-07 at 16:27 +0200, Jakub Jelinek via Gcc-patches wrote:
> On Thu, May 07, 2020 at 09:59:57AM +0200, Richard Biener wrote:
> > Maybe write A - B + -1 >= A to actually match what you match below
> ...
> > on the plus :c is not needed, canonicalization will put the constant
> > literal second
> > 
> > The previous pattern has a single_use check on the minus, since
> > the result is always "simple" (a single stmt) the :s have no
> > effect (hmm, I guess a genmatch warning for this case might be nice).
> > 
> > And yes, if the TYPE_OVERFLOW_WRAPS checks are unnecessary remove
> > them please, we'll hopefully resist all attempts to ubsan
> > unsigned overflow ...
> 
> So like this if it passes bootstrap/regtest?
> 
> 2020-05-07  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/94913
> 	* match.pd (A - B + -1 >= A to B >= A): New simplification.
> 	(A - B > A to A < B): Don't test TYPE_OVERFLOW_WRAPS which is always
> 	true for TYPE_UNSIGNED integral types.
> 
> 	* gcc.dg/tree-ssa/pr94913.c: New test.
I wouldn't be surprised if this trips issues with -Wuninitialized and the C++
runtime.   I like the change, but the VRP bits which detect overflow tests and
extract ranges are fragile -- though it's also possible your change would
eliminate the need for those bits.

jeff
> 



More information about the Gcc-patches mailing list