public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-9317] tree-optimization/99856 - fix overwideing pattern creation
@ 2021-04-01 9:42 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-04-01 9:42 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:3d705c86c08985af73823b71af21c2ffe2c23758
commit r9-9317-g3d705c86c08985af73823b71af21c2ffe2c23758
Author: Richard Biener <rguenther@suse.de>
Date: Thu Apr 1 09:29:14 2021 +0200
tree-optimization/99856 - fix overwideing pattern creation
This fixes an omission of promoting a bit-precision required precision
to a vector element precision.
2021-04-01 Richard Biener <rguenther@suse.de>
PR tree-optimization/99856
* tree-vect-patterns.c (vect_recog_over_widening_pattern): Promote
precision to vector element precision.
* gcc.dg/vect/pr99856.c: New testcase.
(cherry picked from commit 1cfe48d35e31e905632e37ae6a9cb37d35f9a228)
Diff:
---
gcc/testsuite/gcc.dg/vect/pr99856.c | 33 +++++++++++++++++++++++++++++++++
gcc/tree-vect-patterns.c | 1 +
2 files changed, 34 insertions(+)
diff --git a/gcc/testsuite/gcc.dg/vect/pr99856.c b/gcc/testsuite/gcc.dg/vect/pr99856.c
new file mode 100644
index 00000000000..e5d2a45be57
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr99856.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target vect_unpack } */
+/* { dg-require-effective-target vect_pack_trunc } */
+
+#define SHIFTFORDIV255(a)\
+ ((((a) >> 8) + a) >> 8)
+
+#define DIV255(a)\
+ SHIFTFORDIV255(a + 0x80)
+
+typedef unsigned char uint8_t;
+
+void
+opSourceOver_premul(uint8_t* restrict Rrgba,
+ const uint8_t* restrict Srgba,
+ const uint8_t* restrict Drgba, int len)
+{
+ Rrgba = __builtin_assume_aligned (Rrgba, __BIGGEST_ALIGNMENT__);
+ Srgba = __builtin_assume_aligned (Rrgba, __BIGGEST_ALIGNMENT__);
+ Drgba = __builtin_assume_aligned (Rrgba, __BIGGEST_ALIGNMENT__);
+ int i = 0;
+ for (; i < len*4; i += 4)
+ {
+ uint8_t Sa = Srgba[i + 3];
+ Rrgba[i + 0] = DIV255(Srgba[i + 0] * 255 + Drgba[i + 0] * (255 - Sa));
+ Rrgba[i + 1] = DIV255(Srgba[i + 1] * 255 + Drgba[i + 1] * (255 - Sa));
+ Rrgba[i + 2] = DIV255(Srgba[i + 2] * 255 + Drgba[i + 2] * (255 - Sa));
+ Rrgba[i + 3] = DIV255(Srgba[i + 3] * 255 + Drgba[i + 3] * (255 - Sa));
+ }
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index 4a6ef5377f2..167e1150e70 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -1657,6 +1657,7 @@ vect_recog_over_widening_pattern (stmt_vec_info last_stmt_info, tree *type_out)
/* Apply the minimum efficient precision we just calculated. */
if (new_precision < min_precision)
new_precision = min_precision;
+ new_precision = vect_element_precision (new_precision);
if (new_precision >= TYPE_PRECISION (type))
return NULL;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-01 9:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01 9:42 [gcc r9-9317] tree-optimization/99856 - fix overwideing pattern creation 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).