diff options
author | Richard Henderson <rth@redhat.com> | 2001-12-11 21:58:12 -0800 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2001-12-11 21:58:12 -0800 |
commit | 8deb7514502cebe4e025bd278a511fd930dc28e0 (patch) | |
tree | ae84d54ddf94c6dcc08f43e650d604d6b76df2fb /gcc/combine.c | |
parent | 3dba42519e2aba3e1e48a75c29dd5d2554e1789f (diff) | |
download | gcc-8deb7514502cebe4e025bd278a511fd930dc28e0.zip gcc-8deb7514502cebe4e025bd278a511fd930dc28e0.tar.gz gcc-8deb7514502cebe4e025bd278a511fd930dc28e0.tar.bz2 |
combine.c (simplify_and_const_int): Simplify (AND (PLUS X Y) C) if C has only low bits set and doesn't intersect...
* combine.c (simplify_and_const_int): Simplify (AND (PLUS X Y) C)
if C has only low bits set and doesn't intersect with X or Y.
From-SVN: r47921
Diffstat (limited to 'gcc/combine.c')
-rw-r--r-- | gcc/combine.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/combine.c b/gcc/combine.c index 090f3df..eb61c49 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -7791,6 +7791,23 @@ simplify_and_const_int (x, mode, varop, constop) simplify_and_const_int (NULL_RTX, GET_MODE (varop), XEXP (varop, 1), constop)))); + /* If VAROP is PLUS, and the constant is a mask of low bite, distribute + the AND and see if one of the operands simplifies to zero. If so, we + may eliminate it. */ + + if (GET_CODE (varop) == PLUS + && exact_log2 (constop + 1) >= 0) + { + rtx o0, o1; + + o0 = simplify_and_const_int (NULL_RTX, mode, XEXP (varop, 0), constop); + o1 = simplify_and_const_int (NULL_RTX, mode, XEXP (varop, 1), constop); + if (o0 == const0_rtx) + return o1; + if (o1 == const0_rtx) + return o0; + } + /* Get VAROP in MODE. Try to get a SUBREG if not. Don't make a new SUBREG if we already had one (just check for the simplest cases). */ if (x && GET_CODE (XEXP (x, 0)) == SUBREG |