diff options
author | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-03-11 17:45:03 +0000 |
---|---|---|
committer | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-03-11 17:45:03 +0000 |
commit | a22fd5558187765decae31fe6fcf761c4a5468ab (patch) | |
tree | 53c0a411f358defff23d8e0c39b1dc0819424479 /gcc/simplify-rtx.c | |
parent | 5a1672069edec60b352c1ad89d641d8222d44a2e (diff) | |
download | gcc-a22fd5558187765decae31fe6fcf761c4a5468ab.tar.gz |
* fold-const.c (negate_expr_p) <RSHIFT_EXPR>: We can optimize
-((int)X>>C) where C is an integer constant one bit less than the
size of X into (unsigned)X>>C. Similarly for unsigned->signed.
(negate_expr) <RSHIFT_EXPR>: Implement the above transformations.
* simplify-rtx.c (simplify_unary_operation): Also implement the
above transformations at the RTL level.
* gcc.c-torture/execute/20040311-1.c: New test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@79334 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r-- | gcc/simplify-rtx.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 3647c244077..2846bb7a80d 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1013,6 +1013,22 @@ simplify_unary_operation (enum rtx_code code, enum machine_mode mode, XEXP (op, 1)); } + /* (neg (ashiftrt X C)) can be replaced by (lshiftrt X C) when + C is equal to the width of MODE minus 1. */ + if (GET_CODE (op) == ASHIFTRT + && GET_CODE (XEXP (op, 1)) == CONST_INT + && INTVAL (XEXP (op, 1)) == GET_MODE_BITSIZE (mode) - 1) + return simplify_gen_binary (LSHIFTRT, mode, + XEXP (op, 0), XEXP (op, 1)); + + /* (neg (lshiftrt X C)) can be replaced by (ashiftrt X C) when + C is equal to the width of MODE minus 1. */ + if (GET_CODE (op) == LSHIFTRT + && GET_CODE (XEXP (op, 1)) == CONST_INT + && INTVAL (XEXP (op, 1)) == GET_MODE_BITSIZE (mode) - 1) + return simplify_gen_binary (ASHIFTRT, mode, + XEXP (op, 0), XEXP (op, 1)); + break; case SIGN_EXTEND: |