-2019-01-07 Jakub Jelinek <jakub@redhat.com>
+2020-01-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/93156
+ * tree-ssa-ccp.c (bit_value_binop): For x * x note that the second
+ least significant bit is always clear.
PR tree-optimization/93118
* match.pd ((x >> c) << c -> x & (-1<<c)): Add nop_convert?. Add new
-2019-01-07 Jakub Jelinek <jakub@redhat.com>
+2020-01-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/93156
+ * gcc.dg/tree-ssa/pr93156.c: New test.
PR tree-optimization/93118
* gcc.dg/tree-ssa/pr93118.c: New test.
--- /dev/null
+/* PR tree-optimization/93156 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-times "return 0;" 3 "optimized" } } */
+
+int
+foo (int x)
+{
+ return (x * x) & 2;
+}
+
+unsigned long long
+bar (unsigned long long x)
+{
+ return (x * x) & 2;
+}
+
+int
+baz (int x)
+{
+ x &= -2;
+ return (x * x) & 3;
+}
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;