This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: Simplify inside CONST expressions
- From: Andreas Krebbel <krebbel1 at de dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 5 Sep 2005 15:50:22 +0200
- Subject: [PATCH]: Simplify inside CONST expressions
Hi,
I've tried to use simplify_binary_rtx to calculate offsets
between memory addresses. But unfortunately simplify_binary_rtx
refuses to look into CONST expression except there is a single
PLUS inside. But on S/390 there may be something like
<label1> - <label2> which prevents the function
from further simplifications.
So I propose the following patch calling simplify_binary_rtx with
the content of the two CONSTs found in the left and right operands
and wrapping the result into a CONST again.
It workes fine for S/390 but I'm not sure whether it may cause
problems on other platforms.
Bye,
-Andreas-
Index: gcc/simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.244
diff -p -c -r1.244 simplify-rtx.c
*** gcc/simplify-rtx.c 21 Aug 2005 13:27:50 -0000 1.244
--- gcc/simplify-rtx.c 25 Aug 2005 12:40:22 -0000
*************** simplify_plus_minus (enum rtx_code code,
*** 2720,2726 ****
else if (swap_commutative_operands_p (lhs, rhs))
tem = lhs, lhs = rhs, rhs = tem;
! tem = simplify_binary_operation (ncode, mode, lhs, rhs);
/* Reject "simplifications" that just wrap the two
arguments in a CONST. Failure to do so can result
--- 2720,2736 ----
else if (swap_commutative_operands_p (lhs, rhs))
tem = lhs, lhs = rhs, rhs = tem;
! if (GET_CODE (lhs) == CONST && GET_CODE (rhs) == CONST
! && GET_MODE (lhs) == GET_MODE (rhs))
! {
! tem = simplify_binary_operation (ncode, mode,
! XEXP (lhs, 0),
! XEXP (rhs, 0));
! if (!CONSTANT_P (tem))
! tem = gen_rtx_CONST (GET_MODE (lhs), tem);
! }
! else
! tem = simplify_binary_operation (ncode, mode, lhs, rhs);
/* Reject "simplifications" that just wrap the two
arguments in a CONST. Failure to do so can result