]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/117417 - ICE with complex load optimization
authorRichard Biener <rguenther@suse.de>
Tue, 12 Nov 2024 10:15:15 +0000 (11:15 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 17 Jan 2025 08:56:39 +0000 (09:56 +0100)
When we decompose a complex load only used as real and imaginary
parts we fail to honor IL constraints which are that a BIT_FIELD_REF
of register type should be outermost in a ref.  The following
simply avoids the transform when the complex load has such a
BIT_FIELD_REF.

PR tree-optimization/117417
* tree-ssa-forwprop.cc (pass_forwprop::execute): Avoid
decomposing BIT_FIELD_REF complex load.

* gcc.dg/torture/pr117417.c: New testcase.

(cherry picked from commit d976daa931642d940b7b27032ca6139210c07eed)

gcc/testsuite/gcc.dg/torture/pr117417.c [new file with mode: 0644]
gcc/tree-ssa-forwprop.cc

diff --git a/gcc/testsuite/gcc.dg/torture/pr117417.c b/gcc/testsuite/gcc.dg/torture/pr117417.c
new file mode 100644 (file)
index 0000000..2c80dd5
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+typedef __attribute__((__vector_size__ (8))) double V;
+int bar (int a, V *p)
+{
+  V v;
+  v = *p;
+  a += *(_Complex short *) &v;
+  return a;
+}
+V x;
+int
+foo ()
+{
+  return bar (0, &x);
+}
index 062f5667f14a65990329b826e3d4dfb3139337c3..1b36ffb0bbe7b3c62fdc2573eaa1ff590da11e07 100644 (file)
@@ -3542,9 +3542,9 @@ pass_forwprop::execute (function *fun)
          else if (TREE_CODE (TREE_TYPE (lhs)) == COMPLEX_TYPE
                   && gimple_assign_load_p (stmt)
                   && !gimple_has_volatile_ops (stmt)
-                  && (TREE_CODE (gimple_assign_rhs1 (stmt))
-                      != TARGET_MEM_REF)
-                  && !stmt_can_throw_internal (cfun, stmt))
+                  && TREE_CODE (rhs) != TARGET_MEM_REF
+                  && TREE_CODE (rhs) != BIT_FIELD_REF
+                  && !stmt_can_throw_internal (fun, stmt))
            {
              /* Rewrite loads used only in real/imagpart extractions to
                 component-wise loads.  */