From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by sourceware.org (Postfix) with ESMTPS id 3379F3858D3C for ; Mon, 24 Apr 2023 12:06:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3379F3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2a8b3ecf59fso40852041fa.0 for ; Mon, 24 Apr 2023 05:06:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682338004; x=1684930004; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=StLWITahqlDDfESzk7Np+I5fBKRC4ItlNCor1z5hcEw=; b=EU0ymrMMdUzptYS713Yimbq7zYQYVO1yTK6xe04WQEtqcTjm+wNoukOCZNxjGyfZJH U3kkzlHB9Da8M7OLvzpq7/AJ4u9qOMBAKgsqy6xRQLQpLYB9uTiVQ/fA28D0BK0xftS8 T0wqJOge99nYqCqSQ6lRLE7g7H0YsDltj9vbUDdkADyIjOH//vwK0mz0qGI5LBeE0flq aETqUrYvogKJ1OStZkLDj5sEhchYC3yHVn32RMMqewb8fDiC9gyOTQ5QR3ucYDfjYw7g z1ZMk3Ry0YF70cpY640L8aOf9GZPBMx6lRwFgZ7Ye3jrKwXwLJptL1j5GYf6/M5pi1lu blWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682338004; x=1684930004; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=StLWITahqlDDfESzk7Np+I5fBKRC4ItlNCor1z5hcEw=; b=QgCIyY7I94y4eiK2YMFmhEoicqms6xZnT/ym6dqZ0sYl0DCcDuqeCUoXIC5+HblVPJ jQrMgDt/X3nooV4mmvyhvxptR20g7VrRcR23Ogp9M5PVtdqVUzNt3mUJdDIg44Ia6zbi kNpkzMemgcsScJo7NgsBAVW6y1kwoAMFNMJDcbp+rQL0728kFcmJojmSGVfvZcFsOWGS QR3F5HAJDRJ/kR69jvJlXz/A5FndITiXoJ1YifauX7phnzgJ6MFqOKTzD34cao62uqsz NM3z8mvQJrKhGlGNQYjxQYwgPY6sc8FoVQj+taibwC2dCpmDBFeLIqDOYfO6Ipzv3p6h aHLw== X-Gm-Message-State: AAQBX9fVBtYH529v+JXlqn682NV1syexr6d+eOfimC29vVPN46vbRAUv ZRM6UisIpmQlUk5lg1fZvIUDp37B52Pr5Wua+gA= X-Google-Smtp-Source: AKy350aeYodTZ9pFSzeTwUE5I+m5EpP75R0R2mdOIk9kRyBu6/UG2/BHnkRaJ0ySwv5cCQr35jqJgXWqamVffsd3OSE= X-Received: by 2002:a2e:721a:0:b0:2a7:7690:8dec with SMTP id n26-20020a2e721a000000b002a776908decmr2667717ljc.39.1682338004495; Mon, 24 Apr 2023 05:06:44 -0700 (PDT) MIME-Version: 1.0 References: <20230422220921.452264-1-apinski@marvell.com> <20230422220921.452264-6-apinski@marvell.com> In-Reply-To: <20230422220921.452264-6-apinski@marvell.com> From: Richard Biener Date: Mon, 24 Apr 2023 14:05:19 +0200 Message-ID: Subject: Re: [PATCH 5/6] PHIOPT: Ignore predicates for match-and-simplify phi-opt To: Andrew Pinski Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sun, Apr 23, 2023 at 12:11=E2=80=AFAM Andrew Pinski via Gcc-patches wrote: > > This fixes a missed optimization where early phi-opt would > not work when there was predicates. The easiest fix is > to change empty_bb_or_one_feeding_into_p to ignore those > statements while checking for only feeding statement. > > Note phi-opt-23.c and phi-opt-24.c still fail as we don't handle > diamond form in match_and_simplify phiopt yet. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. OK. > gcc/ChangeLog: > > * tree-ssa-phiopt.cc (empty_bb_or_one_feeding_into_p): > Instead of calling last_and_only_stmt, look for the last statemen= t > manually. > > gcc/testsuite/ChangeLog: > > * gcc.dg/tree-ssa/ssa-ifcombine-13.c: Add -fno-ssa-phiopt. > --- > .../gcc.dg/tree-ssa/ssa-ifcombine-13.c | 4 +++- > gcc/tree-ssa-phiopt.cc | 22 +++++++++++++++++-- > 2 files changed, 23 insertions(+), 3 deletions(-) > > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c b/gcc/tests= uite/gcc.dg/tree-ssa/ssa-ifcombine-13.c > index 425eb3d6481..7976544c79b 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c > @@ -1,5 +1,7 @@ > /* { dg-do compile } */ > -/* { dg-options "-O1 -fdump-tree-optimized-details-blocks --param logica= l-op-non-short-circuit=3D1" } */ > +/* Disable phi-opt as it is no longer confused by predicate which had al= lowed ifcombine to work in the past. > + Note this testcase is about ifcombine rather than phi-opt. */ > +/* { dg-options "-O1 -fdump-tree-optimized-details-blocks --param logica= l-op-non-short-circuit=3D1 -fno-ssa-phiopt" } */ > > _Bool f1(_Bool a, _Bool b) > { > diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc > index cb4d8788b56..ffd6a4e6f35 100644 > --- a/gcc/tree-ssa-phiopt.cc > +++ b/gcc/tree-ssa-phiopt.cc > @@ -962,9 +962,27 @@ empty_bb_or_one_feeding_into_p (basic_block bb, > if (!gimple_seq_empty_p (phi_nodes (bb))) > return false; > > - stmt_to_move =3D last_and_only_stmt (bb); > + gimple_stmt_iterator gsi; > + > + gsi =3D gsi_start_nondebug_after_labels_bb (bb); > + while (!gsi_end_p (gsi)) > + { > + gimple *s =3D gsi_stmt (gsi); > + gsi_next_nondebug (&gsi); > + /* Skip over Predict and nop statements. */ > + if (gimple_code (s) =3D=3D GIMPLE_PREDICT > + || gimple_code (s) =3D=3D GIMPLE_NOP) > + continue; > + /* If there is more one statement return false. */ > + if (stmt_to_move) > + return false; > + stmt_to_move =3D s; > + } > + > + /* The only statement here was a Predict or a nop statement > + so return true. */ > if (!stmt_to_move) > - return false; > + return true; > > if (gimple_vuse (stmt_to_move)) > return false; > -- > 2.39.1 >