[PATCH] PR tree-optimization/96779 Adding a missing pattern to match.pd
Richard Biener
richard.guenther@gmail.com
Fri Nov 19 11:43:36 GMT 2021
On Tue, Nov 16, 2021 at 11:51 PM Navid Rahimi via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi GCC community,
>
> This patch will add the missed pattern described in bug 102232 [1] to the match.pd.
>
> Tree-optimization/96779: Adding new optimization to match.pd:
>
> * match.pd (-x == x) -> (x == 0): New optimization.
> * gcc.dg/tree-ssa/pr96779.c: testcase for this optimization.
> * gcc.dg/tree-ssa/pr96779-disabled.c: testcase for this optimization when -fwrapv passed.
>
> 1) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96779
+/* -x == x -> x == 0 */
+(for cmp (eq ne)
+ (simplify
+ (cmp:c @0 (negate @0))
+ (if (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0))
+ && !TYPE_OVERFLOW_WRAPS (type))
you need to check TYPE_OVERFLOW_WRAPS on TREE_TYPE (@0),
otherwise you check on boolean.
+ (cmp:c @0 { build_zero_cst (TREE_TYPE(@0)); }))))
+
no need for :c on the result pattern. Otherwise it looks OK, but how
did you check the patch?
Thanks,
Richard.
> Best wishes,
> Navid.
More information about the Gcc-patches
mailing list