public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/aoliva/heads/testme)] harden-conditionals: detach values before compares
Date: Thu,  8 Jun 2023 10:42:22 +0000 (GMT)	[thread overview]
Message-ID: <20230608104222.9053A385700D@sourceware.org> (raw)

https://gcc.gnu.org/g:848936fda2abec8bb78a4b96d1437990421fcae5

commit 848936fda2abec8bb78a4b96d1437990421fcae5
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu Apr 27 02:43:48 2023 -0300

    harden-conditionals: detach values before compares
    
    The optimization barriers inserted after compares enable GCC to derive
    information about the values from e.g. the taken paths, or the absence
    of exceptions.  Move them before the original compares, so that the
    reversed compares test copies of the original operands, without
    further optimizations.
    
    
    for  gcc/ChangeLog
    
            * gimple-harden-conditionals.cc (insert_edge_check_and_trap):
            Move detach value calls...
            (pass_harden_conditional_branches::execute): ... here.
            (pass_harden_compares::execute): Detach values before
            compares.
    
    for  gcc/testsuite/ChangeLog
    
            * c-c++-common/torture/harden-cond-comp.c: New.

Diff:
---
 gcc/testsuite/c-c++-common/torture/harden-cond-comp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/torture/harden-cond-comp.c b/gcc/testsuite/c-c++-common/torture/harden-cond-comp.c
index dcf364ee993..5aad890a1d3 100644
--- a/gcc/testsuite/c-c++-common/torture/harden-cond-comp.c
+++ b/gcc/testsuite/c-c++-common/torture/harden-cond-comp.c
@@ -1,11 +1,11 @@
 /* { dg-do compile } */
 /* { dg-options "-fharden-conditional-branches -fharden-compares -fdump-tree-hardcbr -fdump-tree-hardcmp -ffat-lto-objects" } */
 
-int f(int i, int j, int k, int l) {
+int f(int i, int j) {
   if (i == 0)
-    return (j != 0) + l;
+    return j != 0;
   else
-    return (i * j != 0) * k;
+    return i * j != 0;
 }
 
 /* { dg-final { scan-tree-dump-times "Splitting edge" 2 "hardcbr" } } */

             reply	other threads:[~2023-06-08 10:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-08 10:42 Alexandre Oliva [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-06-09  6:16 Alexandre Oliva
2023-04-27  7:07 Alexandre Oliva
2023-04-27  5:59 Alexandre Oliva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230608104222.9053A385700D@sourceware.org \
    --to=aoliva@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).