summaryrefslogtreecommitdiff
path: root/gcc/simplify-rtx.c
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2006-03-03 05:55:02 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2006-03-03 05:55:02 +0000
commit4a9a1e2b3160e09b09cf4200a4ae7936b5130439 (patch)
tree141afc731966bde556ecd0d21f0b4225099403fd /gcc/simplify-rtx.c
parent2bd412b30b89f6c5ae67f234e68ae94864ca7c79 (diff)
downloadgcc-4a9a1e2b3160e09b09cf4200a4ae7936b5130439.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111671 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r--gcc/simplify-rtx.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index aded68e52df..754464d06f1 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;