tree-ssa-dom.c (simplify_switch_and_lookup_avail_expr): Look through any value-preser...
authorRichard Henderson <rth@redhat.com>
Thu, 8 Jul 2004 00:03:08 +0000 (17:03 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Thu, 8 Jul 2004 00:03:08 +0000 (17:03 -0700)
        * tree-ssa-dom.c (simplify_switch_and_lookup_avail_expr): Look
        through any value-preserving cast.

From-SVN: r84244

gcc/ChangeLog
gcc/tree-ssa-dom.c

index 33be083356c737ca1cf2dac5d34cc1c6cbaf1608..11e1eb01bf18450529e95c2d8bcb93f9fabab28e 100644 (file)
@@ -1,3 +1,8 @@
+2004-07-07  Richard Henderson  <rth@redhat.com>
+
+       * tree-ssa-dom.c (simplify_switch_and_lookup_avail_expr): Look
+       through any value-preserving cast.
+
 2004-07-07  Alexandre Oliva  <aoliva@redhat.com>
 
        * function.c (assign_parm_find_data_types): Call
index c03e2bb06752cb6063d0cdf0c9af009edf3b8e09..740fe9bc9b2d42c36e2e4f2411c515b6997f1911 100644 (file)
@@ -2460,15 +2460,33 @@ simplify_switch_and_lookup_avail_expr (tree stmt,
          def = TREE_OPERAND (def, 1);
          if (TREE_CODE (def) == NOP_EXPR)
            {
+             int need_precision;
+             bool fail;
+
              def = TREE_OPERAND (def, 0);
+
+#ifdef ENABLE_CHECKING
+             /* ??? Why was Jeff testing this?  We are gimple...  */
+             if (!is_gimple_val (def))
+               abort ();
+#endif
+
              to = TREE_TYPE (cond);
              ti = TREE_TYPE (def);
 
-             /* If we have an extension that preserves sign, then we
+             /* If we have an extension that preserves value, then we
                 can copy the source value into the switch.  */
-             if (TYPE_UNSIGNED (to) == TYPE_UNSIGNED (ti)
-                 && TYPE_PRECISION (to) >= TYPE_PRECISION (ti)
-                 && is_gimple_val (def))
+
+             need_precision = TYPE_PRECISION (ti);
+             fail = false;
+             if (TYPE_UNSIGNED (to) && !TYPE_UNSIGNED (ti))
+               fail = true;
+             else if (!TYPE_UNSIGNED (to) && TYPE_UNSIGNED (ti))
+               need_precision += 1;
+             if (TYPE_PRECISION (to) < need_precision)
+               fail = true;
+
+             if (!fail)
                {
                  SWITCH_COND (stmt) = def;
                  ann->modified = 1;