OSDN Git Service

* simplify-rtx.c (simplify_unary_operation): When simplifying
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 3 Mar 2006 05:55:02 +0000 (05:55 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 3 Mar 2006 05:55:02 +0000 (05:55 +0000)
(neg (lt X 0)) into (ashiftrt X C) or (lshiftrt X C), make sure
that we perform the right shift in the appropriate mode, and
then extend or truncate the result to requested mode.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111671 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/simplify-rtx.c

index a2508b6..7b330e5 100644 (file)
@@ -1,3 +1,10 @@
+2006-03-02  Roger Sayle  <roger@eyesopen.com>
+
+       * simplify-rtx.c (simplify_unary_operation): When simplifying
+       (neg (lt X 0)) into (ashiftrt X C) or (lshiftrt X C), make sure
+       that we perform the right shift in the appropriate mode, and
+       then extend or truncate the result to requested mode.
+
 2006-03-03  Zdenek Dvorak <dvorakz@suse.cz>
 
        * gengtype.c (main): Handle double_int type.
@@ -16,7 +23,8 @@
 
 2006-03-02  Zdenek Dvorak <dvorakz@suse.cz>
 
-       * tree-vrp.c (remove_range_assertions): Do not update statements unnecessarily.
+       * tree-vrp.c (remove_range_assertions): Do not update statements
+       unnecessarily.
 
 2006-03-02  Zdenek Dvorak <dvorakz@suse.cz>
 
index aded68e..754464d 100644 (file)
@@ -590,12 +590,28 @@ simplify_unary_operation_1 (enum rtx_code code, enum machine_mode mode, rtx op)
       if (GET_CODE (op) == LT
          && XEXP (op, 1) == const0_rtx)
        {
+         enum machine_mode inner = GET_MODE (XEXP (op, 0));
+         int isize = GET_MODE_BITSIZE (inner);
          if (STORE_FLAG_VALUE == 1)
-           return simplify_gen_binary (ASHIFTRT, mode, XEXP (op, 0),
-                                       GEN_INT (GET_MODE_BITSIZE (mode) - 1));
+           {
+             temp = simplify_gen_binary (ASHIFTRT, inner, XEXP (op, 0),
+                                         GEN_INT (isize - 1));
+             if (mode == inner)
+               return temp;
+             if (GET_MODE_BITSIZE (mode) > isize)
+               return simplify_gen_unary (SIGN_EXTEND, mode, temp, inner);
+             return simplify_gen_unary (TRUNCATE, mode, temp, inner);
+           }
          else if (STORE_FLAG_VALUE == -1)
-           return simplify_gen_binary (LSHIFTRT, mode, XEXP (op, 0),
-                                       GEN_INT (GET_MODE_BITSIZE (mode) - 1));
+           {
+             temp = simplify_gen_binary (LSHIFTRT, inner, XEXP (op, 0),
+                                         GEN_INT (isize - 1));
+             if (mode == inner)
+               return temp;
+             if (GET_MODE_BITSIZE (mode) > isize)
+               return simplify_gen_unary (ZERO_EXTEND, mode, temp, inner);
+             return simplify_gen_unary (TRUNCATE, mode, temp, inner);
+           }
        }
       break;