Hi Richard, Thanks for the detailed comment. I am attaching a newer version of the patch which does have required fixes included. Bellow you can see my response to your feedbacks:
> you need to check TYPE_OVERFLOW_WRAPS on TREE_TYPE (@0), > otherwise you check on boolean. Fixed it. > no need for :c on the result pattern. Otherwise it looks OK, but how > did you check the patch? Fixed it. For checking the patch, I have script which builds and runs make check for 1) trunk and 2) trunk+patch in a separate directory and diffs the test results from each directory. My test script did had a subtle problem. The bug was, because of a typo in the path I introduced few days ago, it was diffing same trunk+patch test results against trunk+patch test results. That was a good reminder to setup an account for myself here asap [1]. 1) https://gcc.gnu.org/wiki/CompileFarm Best wishes, Navid. ________________________________________ From: Richard Biener <richard.guent...@gmail.com> Sent: Friday, November 19, 2021 03:43 To: Navid Rahimi Cc: Navid Rahimi via Gcc-patches Subject: [EXTERNAL] Re: [PATCH] PR tree-optimization/96779 Adding a missing pattern to match.pd [You don't often get email from richard.guent...@gmail.com. Learn why this is important at http://aka.ms/LearnAboutSenderIdentification.] 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://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgcc.gnu.org%2Fbugzilla%2Fshow_bug.cgi%3Fid%3D96779&data=04%7C01%7Cnavidrahimi%40microsoft.com%7C11c3214ef8164af4d50008d9ab51d9bc%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637729190792397989%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=mxYBk6rex%2Bq5UMot%2BWfJqXeTYEYuM16hrvLGyp4PGeI%3D&reserved=0 +/* -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.
0001-tree-optimization-96779-v2.patch
Description: 0001-tree-optimization-96779-v2.patch