diff options
author | Roger Sayle <roger@eyesopen.com> | 2005-01-14 04:17:13 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2005-01-14 04:17:13 +0000 |
commit | a0ee8b5f99e1d646105e0f916ae443f1c512b454 (patch) | |
tree | 219dd8772e524e69adedf45921c3ce4d94414a50 /gcc | |
parent | 9201889788a05b22a915f91eb06e6bd9ac0f8f4b (diff) | |
download | gcc-a0ee8b5f99e1d646105e0f916ae443f1c512b454.zip gcc-a0ee8b5f99e1d646105e0f916ae443f1c512b454.tar.gz gcc-a0ee8b5f99e1d646105e0f916ae443f1c512b454.tar.bz2 |
simplify-rtx.c (simplify_binary_operation): Optimize (and (sign_extend X) C) into (zero_extend (and X C)).
* simplify-rtx.c (simplify_binary_operation) <AND>: Optimize
(and (sign_extend X) C) into (zero_extend (and X C)).
From-SVN: r93629
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 19 |
2 files changed, 23 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bf7f096..d148319 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,8 +1,12 @@ +2005-01-13 Roger Sayle <roger@eyesopen.com> + + * simplify-rtx.c (simplify_binary_operation) <AND>: Optimize + (and (sign_extend X) C) into (zero_extend (and X C)). + 2005-01-13 David O'Brien <obrien@FreeBSD.org> * config/freebsd-spec.h: Make KSE pthread lib logic the default. - 2005-01-13 Richard Henderson <rth@redhat.com> PR target/19009 diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 0aa1e95..91df355 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1,6 +1,6 @@ /* RTL simplification functions for GNU compiler. Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GCC. @@ -1910,6 +1910,23 @@ simplify_binary_operation (enum rtx_code code, enum machine_mode mode, && ! side_effects_p (op0) && GET_MODE_CLASS (mode) != MODE_CC) return const0_rtx; + + /* Transform (and (extend X) C) into (zero_extend (and X C)) if + there are no non-zero bits of C outside of X's mode. */ + if ((GET_CODE (op0) == SIGN_EXTEND + || GET_CODE (op0) == ZERO_EXTEND) + && GET_CODE (trueop1) == CONST_INT + && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT + && (~GET_MODE_MASK (GET_MODE (XEXP (op0, 0))) + & INTVAL (trueop1)) == 0) + { + enum machine_mode imode = GET_MODE (XEXP (op0, 0)); + tem = simplify_gen_binary (AND, imode, XEXP (op0, 0), + gen_int_mode (INTVAL (trueop1), + imode)); + return simplify_gen_unary (ZERO_EXTEND, mode, tem, imode); + } + /* For constants M and N, if M == (1LL << cst) - 1 && (N & M) == M, ((A & N) + B) & M -> (A + B) & M Similarly if (N & M) == 0, |