aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-01-07 11:05:14 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2020-01-07 11:05:14 +0100
commitfb862fdfb53ecb189f8bd74b66de573a78045916 (patch)
tree733c1ab99c29a45d7184f0131b1ae75029058b62 /gcc/tree-ssa-ccp.c
parentf26916c2acdda19e36e57fff97b296897ebcba76 (diff)
downloadgcc-fb862fdfb53ecb189f8bd74b66de573a78045916.zip
gcc-fb862fdfb53ecb189f8bd74b66de573a78045916.tar.gz
gcc-fb862fdfb53ecb189f8bd74b66de573a78045916.tar.bz2
re PR tree-optimization/93156 (abused nonnull attribute evokes new segfault in gcc 10 since Nov 4 commit, 0fb958ab8aa)
PR tree-optimization/93156 * tree-ssa-ccp.c (bit_value_binop): For x * x note that the second least significant bit is always clear. * gcc.dg/tree-ssa/pr93156.c: New test. From-SVN: r279951
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index add3d3f..be6647d 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1650,6 +1650,17 @@ bit_value_binop (enum tree_code code, tree type, tree rhs1, tree rhs2)
TYPE_SIGN (TREE_TYPE (rhs2)), TYPE_PRECISION (TREE_TYPE (rhs2)),
value_to_wide_int (r2val), r2val.mask);
+ /* (x * x) & 2 == 0. */
+ if (code == MULT_EXPR && rhs1 == rhs2 && TYPE_PRECISION (type) > 1)
+ {
+ widest_int m = 2;
+ if (wi::sext (mask, TYPE_PRECISION (type)) != -1)
+ value = wi::bit_and_not (value, m);
+ else
+ value = 0;
+ mask = wi::bit_and_not (mask, m);
+ }
+
if (wi::sext (mask, TYPE_PRECISION (type)) != -1)
{
val.lattice_val = CONSTANT;