From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 665A43865C2A for ; Thu, 24 Mar 2022 07:28:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 665A43865C2A Received: by mail-ej1-x634.google.com with SMTP id p15so7321263ejc.7 for ; Thu, 24 Mar 2022 00:28:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pEmRr2pvh7sl/vuQcawCy/eGMbGDO61QvrwweybM9hQ=; b=rniiDbnI3Cd8MIfwF/qgqS7M+Q32aSHeOVCJF7nHP2eumhx8TCaph8pArz4p5jZrpM EmMuwxqQII7+Pa1IOGCYYfq3F64w6DqpqmzamNb6EIFBPtquFACxjh+d9k6byZvIIC3U Uw0Pz5Hk1z3fVas8iaRsbGUz5Wqri8RT/N3i8C5RT0T+jUXdWsU/+ULidBSO3d13BdTP uw7K4ujlF2em21wP4675z5ziqDIgVInBujXgyCfqLwYusmCziv0IhV0VZdlxiAFb/4iY E/9hnOi341wY5qS11qxqKPQkDvYEsD76KxmKyp4JgOHHCdRxtqJCFFnFVAwsqFjQV0EA PqUw== X-Gm-Message-State: AOAM531U0KwggzhYAiBBKpN6tH2Ji2g6rRk0gCWEfE/GoL8HEMt3omHC Sp1qjECquRIVQ15pWrVEZJ/vecBwKdseC7oAYJJ261dV X-Google-Smtp-Source: ABdhPJyPXVb5B6vYHifiBnHAMVj7y2eWRnX+cQNuCNOzhqwwDFHK0KLECSbnHNSCZYfPpNwiwBH3AO/7h0mD03J4+pc= X-Received: by 2002:a17:906:948:b0:6d6:e479:1fe4 with SMTP id j8-20020a170906094800b006d6e4791fe4mr4259811ejd.240.1648106905755; Thu, 24 Mar 2022 00:28:25 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Thu, 24 Mar 2022 08:28:14 +0100 Message-ID: Subject: Re: hardcmp: split before dispatch edge To: Alexandre Oliva Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.6 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Mar 2022 07:28:29 -0000 On Thu, Mar 24, 2022 at 2:43 AM Alexandre Oliva via Gcc-patches wrote: > > > If we harden a compare at the end of a block with an edge to the > abnormal dispatch block, it won't have a single successor. Arrange to > split the block at its final stmt so as to have a single succ. > > Regstrapped on x86_64-linux-gnu. Ok to install? OK. > > for gcc/ChangeLog > > PR middle-end/104975 > * gimple-harden-conditionals.cc > (pass_harden_compares::execute): Force split in case of > multiple edges. > > for gcc/testsuite/ChangeLog > > PR middle-end/104975 > * gcc.dg/pr104975.c: New. > --- > gcc/gimple-harden-conditionals.cc | 12 +++++++++--- > gcc/testsuite/gcc.dg/pr104975.c | 20 ++++++++++++++++++++ > 2 files changed, 29 insertions(+), 3 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/pr104975.c > > diff --git a/gcc/gimple-harden-conditionals.cc b/gcc/gimple-harden-conditionals.cc > index 6a5fc3fb9e1a2..be01f3ea8c44a 100644 > --- a/gcc/gimple-harden-conditionals.cc > +++ b/gcc/gimple-harden-conditionals.cc > @@ -509,10 +509,16 @@ pass_harden_compares::execute (function *fun) > gsi_insert_before (&gsi_split, asgnck, GSI_SAME_STMT); > > /* We wish to insert a cond_expr after the compare, so arrange > - for it to be at the end of a block if it isn't. */ > - if (!gsi_end_p (gsi_split)) > + for it to be at the end of a block if it isn't, and for it > + to have a single successor in case there's more than > + one, as in PR104975. */ > + if (!gsi_end_p (gsi_split) > + || !single_succ_p (gsi_bb (gsi_split))) > { > - gsi_prev (&gsi_split); > + if (!gsi_end_p (gsi_split)) > + gsi_prev (&gsi_split); > + else > + gsi_split = gsi_last_bb (gsi_bb (gsi_split)); > basic_block obb = gsi_bb (gsi_split); > basic_block nbb = split_block (obb, gsi_stmt (gsi_split))->dest; > gsi_next (&gsi_split); > diff --git a/gcc/testsuite/gcc.dg/pr104975.c b/gcc/testsuite/gcc.dg/pr104975.c > new file mode 100644 > index 0000000000000..04532fc444340 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pr104975.c > @@ -0,0 +1,20 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O1 -fharden-compares -fno-inline -fno-ipa-pure-const" } */ > + > +__attribute__ ((pure, returns_twice)) int > +bar (int); > + > +int > +quux (void) > +{ > + return 0; > +} > + > +int > +foo (short int x) > +{ > + x = !x; > + bar (quux ()); > + > + return x; > +} > > > -- > Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ > Free Software Activist GNU Toolchain Engineer > Disinformation flourishes because many people care deeply about injustice > but very few check the facts. Ask me about