From 8deb7514502cebe4e025bd278a511fd930dc28e0 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 11 Dec 2001 21:58:12 -0800 Subject: 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 --- gcc/combine.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gcc/combine.c') 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 -- cgit v1.1