aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssanames.cc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2024-10-24 14:22:33 +0100
committerRichard Sandiford <richard.sandiford@arm.com>2024-10-24 14:22:33 +0100
commitd6c4badffafa295f6082b7d74de314e131f30a96 (patch)
tree0fd7eb32174e5c36bc140b60b04b9fc3d46e26cc /gcc/tree-ssanames.cc
parentec8e8d359690e7347e6e718cc9254d59f694e138 (diff)
downloadgcc-d6c4badffafa295f6082b7d74de314e131f30a96.zip
gcc-d6c4badffafa295f6082b7d74de314e131f30a96.tar.gz
gcc-d6c4badffafa295f6082b7d74de314e131f30a96.tar.bz2
Handle POLY_INT_CSTs in get_nonzero_bits
This patch extends get_nonzero_bits to handle POLY_INT_CSTs, The easiest (but also most useful) case is that the number of trailing zeros in the runtime value is at least the number of trailing zeros in each individual component. In principle, we could do this for coeffs 1 and above only, and then OR in ceoff 0. This would give ~0x11 for [14, 32], say. But that's future work. gcc/ * tree-ssanames.cc (get_nonzero_bits): Handle POLY_INT_CSTs. * match.pd (with_possible_nonzero_bits): Likewise. gcc/testsuite/ * gcc.target/aarch64/sve/cnt_fold_4.c: New test.
Diffstat (limited to 'gcc/tree-ssanames.cc')
-rw-r--r--gcc/tree-ssanames.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc
index 4f83fcb..ae6a0cd 100644
--- a/gcc/tree-ssanames.cc
+++ b/gcc/tree-ssanames.cc
@@ -502,6 +502,9 @@ get_nonzero_bits (const_tree name)
if (TREE_CODE (name) == INTEGER_CST)
return wi::to_wide (name);
+ if (POLY_INT_CST_P (name))
+ return -known_alignment (wi::to_poly_wide (name));
+
/* Use element_precision instead of TYPE_PRECISION so complex and
vector types get a non-zero precision. */
unsigned int precision = element_precision (TREE_TYPE (name));