]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/115694 - ICE with complex store rewrite
authorRichard Biener <rguenther@suse.de>
Sun, 30 Jun 2024 11:07:14 +0000 (13:07 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 1 Jul 2024 05:56:57 +0000 (07:56 +0200)
The following adds a missed check when forwprop attempts to rewrite
a complex store.

PR tree-optimization/115694
* tree-ssa-forwprop.cc (pass_forwprop::execute): Check the
store is complex before rewriting it.

* g++.dg/torture/pr115694.C: New testcase.

gcc/testsuite/g++.dg/torture/pr115694.C [new file with mode: 0644]
gcc/tree-ssa-forwprop.cc

diff --git a/gcc/testsuite/g++.dg/torture/pr115694.C b/gcc/testsuite/g++.dg/torture/pr115694.C
new file mode 100644 (file)
index 0000000..bbce47d
--- /dev/null
@@ -0,0 +1,13 @@
+// { dg-do compile }
+
+_Complex a;
+typedef struct {
+  double a[2];
+} b;
+void c(b);
+void d()
+{
+  _Complex b1 = a;
+  b t = __builtin_bit_cast (b, b1);
+  c(t);
+}
index 05d42ccd3c619fac42d4d1c58d6610451bf60bc9..abf71f0d3a038399ea4fc876c828e95ecc0b1510 100644 (file)
@@ -3762,6 +3762,8 @@ pass_forwprop::execute (function *fun)
                  && gimple_store_p (use_stmt)
                  && !gimple_has_volatile_ops (use_stmt)
                  && is_gimple_assign (use_stmt)
+                 && (TREE_CODE (TREE_TYPE (gimple_assign_lhs (use_stmt)))
+                     == COMPLEX_TYPE)
                  && (TREE_CODE (gimple_assign_lhs (use_stmt))
                      != TARGET_MEM_REF))
                {