[PATCH] expand: Fold x - y < 0 to x < y during expansion [PR94802]

Jeff Law law@redhat.com
Tue Jan 5 17:19:18 GMT 2021



On 1/5/21 8:30 AM, Jakub Jelinek wrote:
> Hi!
>
> My earlier patch to simplify x - y < 0 etc. for signed subtraction
> with undefined overflow into x < y in match.pd regressed some tests,
> even when it was guarded to be post-IPA, the following patch thus
> attempts to optimize that during expansion instead (which is the last
> time we can do it, afterwards we lose the information whether it was
> x - y < 0 or (int) ((unsigned) x - y) < 0 for which we couldn't
> optimize it.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2021-01-05  Jakub Jelinek  <jakub@redhat.com>
>
> 	PR tree-optimization/94802
> 	* expr.h (maybe_optimize_sub_cmp_0): Declare.
> 	* expr.c: Include tree-pretty-print.h and flags.h.
> 	(maybe_optimize_sub_cmp_0): New function.
> 	(do_store_flag): Use it.
> 	* cfgexpand.c (expand_gimple_cond): Likewise.
>
> 	* gcc.target/i386/pr94802.c: New test.
> 	* gcc.dg/Wstrict-overflow-25.c: Remove xfail.
OK
jeff



More information about the Gcc-patches mailing list