diff options
author | nemet <nemet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-07-09 05:43:56 +0000 |
---|---|---|
committer | nemet <nemet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-07-09 05:43:56 +0000 |
commit | 85ece28d613b552bc84ca915ea018dde41c0ac02 (patch) | |
tree | b15ea351d95755f96844045e63fdbd14ec86dbcd /gcc/simplify-rtx.c | |
parent | 658e15232bc46902b731b3249ec79781fb43f2f3 (diff) | |
download | gcc-85ece28d613b552bc84ca915ea018dde41c0ac02.tar.gz |
* simplify-rtx.c (simplify_binary_operation_1) <AND>: Transform (and
(truncate)) into (truncate (and)).
testsuite/
* gcc.target/mips/truncate-5.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149402 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r-- | gcc/simplify-rtx.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 782d7172091..ff690684ee6 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2336,6 +2336,18 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode, return simplify_gen_unary (ZERO_EXTEND, mode, tem, imode); } + /* Transform (and (truncate X) C) into (truncate (and X C)). This way + we might be able to further simplify the AND with X and potentially + remove the truncation altogether. */ + if (GET_CODE (op0) == TRUNCATE && CONST_INT_P (trueop1)) + { + rtx x = XEXP (op0, 0); + enum machine_mode xmode = GET_MODE (x); + tem = simplify_gen_binary (AND, xmode, x, + gen_int_mode (INTVAL (trueop1), xmode)); + return simplify_gen_unary (TRUNCATE, mode, tem, xmode); + } + /* Canonicalize (A | C1) & C2 as (A & C2) | (C1 & C2). */ if (GET_CODE (op0) == IOR && CONST_INT_P (trueop1) |