public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5290] Add a missing return when transforming atomic bit test and operations
@ 2021-11-16  3:24 H.J. Lu
  0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2021-11-16  3:24 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:074ee8d9a91d7573c1e8774a22e4e08f923adb18

commit r12-5290-g074ee8d9a91d7573c1e8774a22e4e08f923adb18
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Nov 15 17:37:10 2021 -0800

    Add a missing return when transforming atomic bit test and operations
    
    When failing to transform equivalent, but slighly different cases of
    atomic bit test and operations to their canonical forms, return
    immediately.
    
    gcc/
    
            PR middle-end/103268
            * tree-ssa-ccp.c (optimize_atomic_bit_test_and): Add a missing
            return.
    
    gcc/testsuite/
    
            PR middle-end/103268
            * gcc.dg/pr103268-1.c: New test.
            * gcc.dg/pr103268-2.c: Likewise.

Diff:
---
 gcc/testsuite/gcc.dg/pr103268-1.c | 10 ++++++++++
 gcc/testsuite/gcc.dg/pr103268-2.c | 12 ++++++++++++
 gcc/tree-ssa-ccp.c                |  2 ++
 3 files changed, 24 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/pr103268-1.c b/gcc/testsuite/gcc.dg/pr103268-1.c
new file mode 100644
index 00000000000..6d583d55d6d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr103268-1.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+extern int si;
+long
+test_types (void)
+{
+  unsigned int u2 = __atomic_fetch_xor (&si, 0, 5);
+  return u2;
+}
diff --git a/gcc/testsuite/gcc.dg/pr103268-2.c b/gcc/testsuite/gcc.dg/pr103268-2.c
new file mode 100644
index 00000000000..12283bb43d9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr103268-2.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+ 
+extern long pscc_a_2_3;
+extern int pscc_a_1_4;
+
+void
+pscc (void)
+{
+  pscc_a_1_4 = __sync_fetch_and_and (&pscc_a_2_3, 1);
+}
+
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 0666dc652d0..18d57729d8a 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -3638,6 +3638,8 @@ optimize_atomic_bit_test_and (gimple_stmt_iterator *gsip,
 	      use_stmt = use_nop_stmt;
 	    }
 	}
+      else
+	return;
 
       if (!bit)
 	{


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-16  3:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16  3:24 [gcc r12-5290] Add a missing return when transforming atomic bit test and operations H.J. Lu

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).