From fb862fdfb53ecb189f8bd74b66de573a78045916 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 7 Jan 2020 11:05:14 +0100 Subject: 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 --- gcc/tree-ssa-ccp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/tree-ssa-ccp.c') 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; -- cgit v1.1