public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5981] Fix ICE. [PR103682]
@ 2021-12-14 23:40 hongtao Liu
  0 siblings, 0 replies; only message in thread
From: hongtao Liu @ 2021-12-14 23:40 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:a2a0c91b47537b16908981e206f4e42db8425eca

commit r12-5981-ga2a0c91b47537b16908981e206f4e42db8425eca
Author: liuhongt <hongtao.liu@intel.com>
Date:   Tue Dec 14 09:47:08 2021 +0800

    Fix ICE. [PR103682]
    
    Check is_gimple_assign before gimple_assign_rhs_code.
    
    gcc/ChangeLog:
    
            PR target/103682
            * tree-ssa-ccp.c (optimize_atomic_bit_test_and): Check
            is_gimple_assign before gimple_assign_rhs_code.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.c-torture/compile/pr103682.c: New test.

Diff:
---
 gcc/testsuite/gcc.c-torture/compile/pr103682.c | 3 +++
 gcc/tree-ssa-ccp.c                             | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.c-torture/compile/pr103682.c b/gcc/testsuite/gcc.c-torture/compile/pr103682.c
new file mode 100644
index 00000000000..5ee4b21f7e6
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr103682.c
@@ -0,0 +1,3 @@
+int bug(unsigned *ready, unsigned u) {
+  return __atomic_fetch_and (ready, ~u, 0) & u;
+}
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 9e12da8f011..a5b1f60f979 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -3703,8 +3703,8 @@ optimize_atomic_bit_test_and (gimple_stmt_iterator *gsip,
 	      g = SSA_NAME_DEF_STMT (mask);
 	    }
 
-	  rhs_code = gimple_assign_rhs_code (g);
-	  if (rhs_code != LSHIFT_EXPR
+	  if (!is_gimple_assign (g)
+	      || gimple_assign_rhs_code (g) != LSHIFT_EXPR
 	      || !integer_onep (gimple_assign_rhs1 (g)))
 	    return;
 	  bit = gimple_assign_rhs2 (g);


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

only message in thread, other threads:[~2021-12-14 23:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 23:40 [gcc r12-5981] Fix ICE. [PR103682] hongtao Liu

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