* [PATCH] middle-end: check that both sides of complex expression is a mul.
@ 2021-11-18 16:57 Tamar Christina
2021-11-18 17:07 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Tamar Christina @ 2021-11-18 16:57 UTC (permalink / raw)
To: gcc-patches; +Cc: nd, rguenther
[-- Attachment #1: Type: text/plain, Size: 2265 bytes --]
Hi All,
Both sides of the VEC_PERM_EXPR need to be a MULT but the check
was accidentally checking if both sides are a mul.
The FMS case would be handled by the validate_multiplication but
this makes the requirement more explicit and we exit earlier.
Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
Ok for master?
Thanks,
Tamar
gcc/ChangeLog:
PR tree-optimizaion/103311
* tree-vect-slp-patterns.c (complex_mul_pattern::matches,
complex_fms_pattern::matches): Check for multiplications.
gcc/testsuite/ChangeLog:
PR tree-optimizaion/103311
* gcc.target/aarch64/pr103311.c: New test.
--- inline copy of patch --
diff --git a/gcc/testsuite/gcc.target/aarch64/pr103311.c b/gcc/testsuite/gcc.target/aarch64/pr103311.c
new file mode 100644
index 0000000000000000000000000000000000000000..7bcc7db79be8f1b4dc1f95c6cf10f5292191a892
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr103311.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_v8_3a_complex_neon_ok } */
+/* { dg-add-options arm_v8_3a_complex_neon } */
+/* { dg-additional-options "-std=c99" } */
+
+_Complex double y;
+
+void
+cbknu (_Complex double f)
+{
+ const _Complex double cone = 1.0e0;
+
+ f = f * cone;
+ y = f * cone;
+}
+
diff --git a/gcc/tree-vect-slp-patterns.c b/gcc/tree-vect-slp-patterns.c
index 53fbe5185f543298b27d084a93c30a1c161d3d32..d916fc9cef9a86a0d797caaf2b2f253685e9b7dd 100644
--- a/gcc/tree-vect-slp-patterns.c
+++ b/gcc/tree-vect-slp-patterns.c
@@ -949,7 +949,7 @@ complex_mul_pattern::matches (complex_operation_t op,
bool mul0 = vect_match_expression_p (l0node[0], MULT_EXPR);
bool mul1 = vect_match_expression_p (l0node[1], MULT_EXPR);
- if (!mul0 && !mul1)
+ if (!mul0 || !mul1)
return IFN_LAST;
/* Now operand2+4 may lead to another expression. */
@@ -1204,7 +1204,9 @@ complex_fms_pattern::matches (complex_operation_t op,
/* 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)
+ if (left_op.length () != 2
+ || right_op.length () != 2
+ || !vect_match_expression_p (l0node[1], MULT_EXPR))
return IFN_LAST;
bool is_neg = vect_normalize_conj_loc (left_op);
--
[-- Attachment #2: rb15095.patch --]
[-- Type: text/x-diff, Size: 1619 bytes --]
diff --git a/gcc/testsuite/gcc.target/aarch64/pr103311.c b/gcc/testsuite/gcc.target/aarch64/pr103311.c
new file mode 100644
index 0000000000000000000000000000000000000000..7bcc7db79be8f1b4dc1f95c6cf10f5292191a892
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr103311.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_v8_3a_complex_neon_ok } */
+/* { dg-add-options arm_v8_3a_complex_neon } */
+/* { dg-additional-options "-std=c99" } */
+
+_Complex double y;
+
+void
+cbknu (_Complex double f)
+{
+ const _Complex double cone = 1.0e0;
+
+ f = f * cone;
+ y = f * cone;
+}
+
diff --git a/gcc/tree-vect-slp-patterns.c b/gcc/tree-vect-slp-patterns.c
index 53fbe5185f543298b27d084a93c30a1c161d3d32..d916fc9cef9a86a0d797caaf2b2f253685e9b7dd 100644
--- a/gcc/tree-vect-slp-patterns.c
+++ b/gcc/tree-vect-slp-patterns.c
@@ -949,7 +949,7 @@ complex_mul_pattern::matches (complex_operation_t op,
bool mul0 = vect_match_expression_p (l0node[0], MULT_EXPR);
bool mul1 = vect_match_expression_p (l0node[1], MULT_EXPR);
- if (!mul0 && !mul1)
+ if (!mul0 || !mul1)
return IFN_LAST;
/* Now operand2+4 may lead to another expression. */
@@ -1204,7 +1204,9 @@ complex_fms_pattern::matches (complex_operation_t op,
/* 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)
+ if (left_op.length () != 2
+ || right_op.length () != 2
+ || !vect_match_expression_p (l0node[1], MULT_EXPR))
return IFN_LAST;
bool is_neg = vect_normalize_conj_loc (left_op);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] middle-end: check that both sides of complex expression is a mul.
2021-11-18 16:57 [PATCH] middle-end: check that both sides of complex expression is a mul Tamar Christina
@ 2021-11-18 17:07 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2021-11-18 17:07 UTC (permalink / raw)
To: Tamar Christina, gcc-patches; +Cc: nd
On November 18, 2021 5:57:45 PM GMT+01:00, Tamar Christina <tamar.christina@arm.com> wrote:
>Hi All,
>
>Both sides of the VEC_PERM_EXPR need to be a MULT but the check
>was accidentally checking if both sides are a mul.
>
>The FMS case would be handled by the validate_multiplication but
>this makes the requirement more explicit and we exit earlier.
>
>Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
>
>Ok for master?
Ok.
Richard.
>Thanks,
>Tamar
>
>
>gcc/ChangeLog:
>
> PR tree-optimizaion/103311
> * tree-vect-slp-patterns.c (complex_mul_pattern::matches,
> complex_fms_pattern::matches): Check for multiplications.
>
>gcc/testsuite/ChangeLog:
>
> PR tree-optimizaion/103311
> * gcc.target/aarch64/pr103311.c: New test.
>
>--- inline copy of patch --
>diff --git a/gcc/testsuite/gcc.target/aarch64/pr103311.c b/gcc/testsuite/gcc.target/aarch64/pr103311.c
>new file mode 100644
>index 0000000000000000000000000000000000000000..7bcc7db79be8f1b4dc1f95c6cf10f5292191a892
>--- /dev/null
>+++ b/gcc/testsuite/gcc.target/aarch64/pr103311.c
>@@ -0,0 +1,16 @@
>+/* { dg-do compile } */
>+/* { dg-require-effective-target arm_v8_3a_complex_neon_ok } */
>+/* { dg-add-options arm_v8_3a_complex_neon } */
>+/* { dg-additional-options "-std=c99" } */
>+
>+_Complex double y;
>+
>+void
>+cbknu (_Complex double f)
>+{
>+ const _Complex double cone = 1.0e0;
>+
>+ f = f * cone;
>+ y = f * cone;
>+}
>+
>diff --git a/gcc/tree-vect-slp-patterns.c b/gcc/tree-vect-slp-patterns.c
>index 53fbe5185f543298b27d084a93c30a1c161d3d32..d916fc9cef9a86a0d797caaf2b2f253685e9b7dd 100644
>--- a/gcc/tree-vect-slp-patterns.c
>+++ b/gcc/tree-vect-slp-patterns.c
>@@ -949,7 +949,7 @@ complex_mul_pattern::matches (complex_operation_t op,
>
> bool mul0 = vect_match_expression_p (l0node[0], MULT_EXPR);
> bool mul1 = vect_match_expression_p (l0node[1], MULT_EXPR);
>- if (!mul0 && !mul1)
>+ if (!mul0 || !mul1)
> return IFN_LAST;
>
> /* Now operand2+4 may lead to another expression. */
>@@ -1204,7 +1204,9 @@ complex_fms_pattern::matches (complex_operation_t op,
>
> /* 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)
>+ if (left_op.length () != 2
>+ || right_op.length () != 2
>+ || !vect_match_expression_p (l0node[1], MULT_EXPR))
> return IFN_LAST;
>
> bool is_neg = vect_normalize_conj_loc (left_op);
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-18 17:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-18 16:57 [PATCH] middle-end: check that both sides of complex expression is a mul Tamar Christina
2021-11-18 17:07 ` Richard Biener
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).