diff options
author | Roger Sayle <sayle@gcc.gnu.org> | 2006-03-03 05:55:02 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2006-03-03 05:55:02 +0000 |
commit | 0f2f71b552e7c1136401c3b7c7d8a28d92aed1bc (patch) | |
tree | 141afc731966bde556ecd0d21f0b4225099403fd | |
parent | e20f951129228f1decc51b4dfe5609cb55806b2a (diff) | |
download | gcc-0f2f71b552e7c1136401c3b7c7d8a28d92aed1bc.zip gcc-0f2f71b552e7c1136401c3b7c7d8a28d92aed1bc.tar.gz gcc-0f2f71b552e7c1136401c3b7c7d8a28d92aed1bc.tar.bz2 |
simplify-rtx.c (simplify_unary_operation): When simplifying (neg (lt X 0)) into (ashiftrt X C) or (lshiftrt X C)...
* 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.
From-SVN: r111671
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 24 |
2 files changed, 29 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a2508b6..7b330e5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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> diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index aded68e..754464d 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -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; |