From 28af4b9a7c5ee9f6c6fc111210639eb2f64bddcd Mon Sep 17 00:00:00 2001 From: Tamar Christina Date: Thu, 25 Feb 2021 16:26:37 +0000 Subject: [PATCH] slp: Don't traverse tree on (nil) nodes. The given testcase shows that one of the children of the complex MUL contains a PHI node. This results in the vectorizer having a child that's (nil). The pattern matcher handles this correctly, but optimize_load_redistribution_1 needs to not traverse/inspect the NULL nodes. This however does high-light a missed opportunity. This testcase seems to result in a different canonicalization than normally. Normally the expressions are right leaning. But sometimes, especially when type casts are introduced the trees suddenly become left leaning. For instance this testcase (even without type casts) won't detect the FMA form because the addition gets the MUL node in the left and not right node as it expects. Checking all forms would be quite expensive so for GCC 12 it probably makes sense to make forms with type casts in them have the same form as those without? gcc/ChangeLog: * tree-vect-slp.c (optimize_load_redistribution_1): Abort on NULL nodes. gcc/testsuite/ChangeLog: * g++.dg/vect/simd-complex-num-null-node.cc: New test. --- .../g++.dg/vect/simd-complex-num-null-node.cc | 78 +++++++++++++++++++ gcc/tree-vect-slp.c | 2 +- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/vect/simd-complex-num-null-node.cc diff --git a/gcc/testsuite/g++.dg/vect/simd-complex-num-null-node.cc b/gcc/testsuite/g++.dg/vect/simd-complex-num-null-node.cc new file mode 100644 index 000000000000..eddf0ad87101 --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/simd-complex-num-null-node.cc @@ -0,0 +1,78 @@ +/* { dg-do compile { target { aarch64-*-* } } } */ +/* { dg-skip-if "incorrect syntax for c++98" { *-*-* } { "-std=c++98" } { "" } } */ +/* { dg-additional-options "-w -O3 -march=armv8.3-a -fdump-tree-vect-all" } */ +/* { dg-require-effective-target le } */ + +typedef struct { + float b; + float c; +} d; +namespace { +typedef int e; +template struct f; +template