aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2021-11-02 13:26:36 +0000
committerTamar Christina <tamar.christina@arm.com>2021-11-02 13:28:15 +0000
commit6cc8aa65fdeaefe9774d5e0d4e72c91f52313be1 (patch)
tree5b5476a458e43186aaad88bf95cd6a07c99636db /gcc
parent268b43d2592c196ea101946d7063156a914b2713 (diff)
downloadgcc-6cc8aa65fdeaefe9774d5e0d4e72c91f52313be1.zip
gcc-6cc8aa65fdeaefe9774d5e0d4e72c91f52313be1.tar.gz
gcc-6cc8aa65fdeaefe9774d5e0d4e72c91f52313be1.tar.bz2
middle-end: Fix PR103007, add missing check on complex fms detection.
The complex FMS detection is missing a check on if the nodes of the VEC_PERM has the amount of children we expect before it recurses. This check is there on MUL and FMA but was missing for FMS, due to this the compiler goes on further than it should and hits an assert. gcc/ChangeLog: PR tree-optimization/103007 * tree-vect-slp-patterns.c (complex_fms_pattern::matches): Add elem check. gcc/testsuite/ChangeLog: PR tree-optimization/103007 * g++.dg/pr103007.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/g++.dg/pr103007.C19
-rw-r--r--gcc/tree-vect-slp-patterns.c6
2 files changed, 24 insertions, 1 deletions
diff --git a/gcc/testsuite/g++.dg/pr103007.C b/gcc/testsuite/g++.dg/pr103007.C
new file mode 100644
index 0000000..1631a85
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr103007.C
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3" } */
+
+typedef float MushMeshVector[4];
+struct MushMeshQuaternionPair {
+ void VectorRotate(MushMeshVector &);
+ MushMeshVector m_first;
+ MushMeshVector m_second;
+};
+void
+MushMeshQuaternionPair::
+VectorRotate(MushMeshVector &ioVec) {
+ ioVec[2] = (2 - m_first[1] + m_first[3] * 0);
+ ioVec[3] = (m_first[3] + m_first[1] - m_first[2] * 0);
+ float c = ioVec[2], d = ioVec[3];
+ ioVec[2] = (0 - d * m_second[1]);
+ ioVec[3] = (2 - c * m_second[1]);
+}
+
diff --git a/gcc/tree-vect-slp-patterns.c b/gcc/tree-vect-slp-patterns.c
index 99dea82..e08a15e 100644
--- a/gcc/tree-vect-slp-patterns.c
+++ b/gcc/tree-vect-slp-patterns.c
@@ -1197,13 +1197,17 @@ complex_fms_pattern::matches (complex_operation_t op,
auto childs = SLP_TREE_CHILDREN (nodes[0]);
auto l0node = SLP_TREE_CHILDREN (childs[0]);
- auto l1node = SLP_TREE_CHILDREN (childs[1]);
/* Now operand2+4 may lead to another expression. */
auto_vec<slp_tree> left_op, right_op;
left_op.safe_splice (SLP_TREE_CHILDREN (l0node[1]));
right_op.safe_splice (SLP_TREE_CHILDREN (nodes[1]));
+ /* If these nodes don't have any children then they're
+ not ones we're interested in. */
+ if (left_op.length () != 2 || right_op.length () != 2)
+ return IFN_LAST;
+
bool is_neg = vect_normalize_conj_loc (left_op);
bool conj_first_operand = false;