gcc/
authorYvan Roux <yvan.roux@linaro.org>
Wed, 14 Sep 2016 09:43:29 +0000 (11:43 +0200)
committerYvan Roux <yvan.roux@linaro.org>
Thu, 15 Sep 2016 11:36:06 +0000 (11:36 +0000)
Backport from trunk r239212.
2016-08-08  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

* tree-ssa-ccp.c (extend_mask): New param sgn.
Remove ORing with wi::mask.
(get_default_value): Adjust call to extend_mask to pass sign.
(evaluate_stmt): Likewise.

Change-Id: Ia929df985c53ccc0b51d35d801f93d29c850a33d

gcc/tree-ssa-ccp.c

index a501d2c..631588d 100644 (file)
@@ -229,13 +229,12 @@ debug_lattice_value (ccp_prop_value_t val)
   fprintf (stderr, "\n");
 }
 
-/* Extend NONZERO_BITS to a full mask, with the upper bits being set.  */
+/* Extend NONZERO_BITS to a full mask, based on sgn.  */ 
 
 static widest_int
-extend_mask (const wide_int &nonzero_bits)
+extend_mask (const wide_int &nonzero_bits, signop sgn)
 {
-  return (wi::mask <widest_int> (wi::get_precision (nonzero_bits), true)
-         | widest_int::from (nonzero_bits, UNSIGNED));
+  return widest_int::from (nonzero_bits, sgn); 
 }
 
 /* Compute a default value for variable VAR and store it in the
@@ -284,7 +283,7 @@ get_default_value (tree var)
                {
                  val.lattice_val = CONSTANT;
                  val.value = build_zero_cst (TREE_TYPE (var));
-                 val.mask = extend_mask (nonzero_bits);
+                 val.mask = extend_mask (nonzero_bits, TYPE_SIGN (TREE_TYPE (var)));
                }
            }
        }
@@ -1934,7 +1933,7 @@ evaluate_stmt (gimple *stmt)
            {
              val.lattice_val = CONSTANT;
              val.value = build_zero_cst (TREE_TYPE (lhs));
-             val.mask = extend_mask (nonzero_bits);
+             val.mask = extend_mask (nonzero_bits, TYPE_SIGN (TREE_TYPE (lhs)));
              is_constant = true;
            }
          else
@@ -1945,7 +1944,8 @@ evaluate_stmt (gimple *stmt)
              if (nonzero_bits == 0)
                val.mask = 0;
              else
-               val.mask = val.mask & extend_mask (nonzero_bits);
+               val.mask = val.mask & extend_mask (nonzero_bits,
+                                                  TYPE_SIGN (TREE_TYPE (lhs)));
            }
        }
     }