aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-06-22 15:22:51 +0200
committerJakub Jelinek <jakub@redhat.com>2021-06-22 15:22:51 +0200
commit3adb9ac6626c15ba21e4eaf27fec95688a3ca8c2 (patch)
treea4ba9a4d0446502288f835834584cf1313d3c86d
parent9b613e825d706b18f69e40edaee3eaf27d28f5cb (diff)
testsuite: Add testcase for recently fixed PR [PR101159]
On Tue, Jun 22, 2021 at 11:00:51AM +0200, Richard Biener wrote: > 2021-06-22 Richard Biener <rguenther@suse.de> > > PR tree-optimization/101159 > * tree-vect-patterns.c (vect_recog_popcount_pattern): Add > missing NULL vectype check. The following patch adds the testcase for it, IMHO it can't hurt and from my experience testcases often trigger other bugs later on (rather than the original bugs reappearing, though even that happens), and also fixes a couple of typos in the new function. 2021-06-22 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/101159 * tree-vect-patterns.c (vect_recog_popcount_pattern): Fix some comment typos. * gcc.c-torture/compile/pr101159.c: New test.
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr101159.c10
-rw-r--r--gcc/tree-vect-patterns.c8
2 files changed, 14 insertions, 4 deletions
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr101159.c b/gcc/testsuite/gcc.c-torture/compile/pr101159.c
new file mode 100644
index 00000000000..81b2d2cafb6
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr101159.c
@@ -0,0 +1,10 @@
+/* PR tree-optimization/101159 */
+
+unsigned long a;
+long b;
+
+void
+foo (void)
+{
+ a += __builtin_popcountl (b);
+}
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index d0a5c71dbe4..b2e7fc2cc7a 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -1300,7 +1300,7 @@ vect_recog_widen_minus_pattern (vec_info *vinfo, stmt_vec_info last_stmt_info,
TYPE1 B;
UTYPE2 temp_in;
TYPE3 temp_out;
- temp_in = (TYPE2)A;
+ temp_in = (UTYPE2)A;
temp_out = __builtin_popcount{,l,ll} (temp_in);
B = (TYPE1) temp_out;
@@ -1372,8 +1372,8 @@ vect_recog_popcount_pattern (vec_info *vinfo,
if (!rhs_origin)
return NULL;
- /* Input and outout of .POPCOUNT should be same-precision integer.
- Also A should be unsigned or same presion as temp_in,
+ /* Input and output of .POPCOUNT should be same-precision integer.
+ Also A should be unsigned or same precision as temp_in,
otherwise there would be sign_extend from A to temp_in. */
if (TYPE_PRECISION (unprom_diff.type) != TYPE_PRECISION (lhs_type)
|| (!TYPE_UNSIGNED (unprom_diff.type)
@@ -1384,7 +1384,7 @@ vect_recog_popcount_pattern (vec_info *vinfo,
vect_pattern_detected ("vec_regcog_popcount_pattern", popcount_stmt);
vec_type = get_vectype_for_scalar_type (vinfo, lhs_type);
- /* Do it only the backend existed popcount<vector_mode>2. */
+ /* Do it only if the backend has popcount<vector_mode>2 pattern. */
if (!vec_type
|| !direct_internal_fn_supported_p (IFN_POPCOUNT, vec_type,
OPTIMIZE_FOR_SPEED))