From 0af94772ae11789901c6b1d1363828db5c91a314 Mon Sep 17 00:00:00 2001 From: rth Date: Wed, 12 Dec 2001 05:58:12 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@47921 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/combine.c | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 53cd3069d42..2cdcef5ce2d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2001-12-11 Richard Henderson + + * 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. + Tue Dec 11 23:58:39 EST 2001 John Wehle (john@feith.com) * basic-block.h (flow_preorder_transversal_compute): Declare. diff --git a/gcc/combine.c b/gcc/combine.c index 090f3dff5c5..eb61c49ecfa 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 -- 2.11.4.GIT