This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
BImode arithmetic simplifications
- To: gcc-patches at gcc dot gnu dot org
- Subject: BImode arithmetic simplifications
- From: Richard Henderson <rth at cygnus dot com>
- Date: Mon, 18 Sep 2000 11:27:36 -0700
Combine already knew that
(not (and (ne x 0) (ne y 0)))
simplifies to
(ior (not (ne x 0)) (not (ne y 0)))
This allows it to continue so that we get
(ior (eq x 0) (eq y 0))
r~
* combine.c (combine_simplify_rtx): Use gen_unary to distribute
the NOT for De Morgan's rule.
* simplify-rtx.c (simplify_unary_operation): Simplify a BImode NOT
of a comparison to the reverse comparison.
Index: combine.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/combine.c,v
retrieving revision 1.152
diff -c -p -d -r1.152 combine.c
*** combine.c 2000/09/18 18:08:19 1.152
--- combine.c 2000/09/18 18:22:15
*************** combine_simplify_rtx (x, op0_mode, last,
*** 3933,3953 ****
if (GET_CODE (XEXP (x, 0)) == IOR || GET_CODE (XEXP (x, 0)) == AND)
{
rtx in1 = XEXP (XEXP (x, 0), 0), in2 = XEXP (XEXP (x, 0), 1);
! if (GET_CODE (in1) == NOT)
! in1 = XEXP (in1, 0);
! else
! in1 = gen_rtx_combine (NOT, GET_MODE (in1), in1);
! if (GET_CODE (in2) == NOT)
! in2 = XEXP (in2, 0);
! else if (GET_CODE (in2) == CONST_INT
! && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
! in2 = GEN_INT (GET_MODE_MASK (mode) & ~INTVAL (in2));
! else
! in2 = gen_rtx_combine (NOT, GET_MODE (in2), in2);
! if (GET_CODE (in2) == NOT)
{
rtx tem = in2;
in2 = in1; in1 = tem;
--- 3933,3949 ----
if (GET_CODE (XEXP (x, 0)) == IOR || GET_CODE (XEXP (x, 0)) == AND)
{
rtx in1 = XEXP (XEXP (x, 0), 0), in2 = XEXP (XEXP (x, 0), 1);
+ enum machine_mode op_mode;
! op_mode = GET_MODE (in1);
! in1 = gen_unary (NOT, op_mode, op_mode, in1);
! op_mode = GET_MODE (in2);
! if (op_mode == VOIDmode)
! op_mode = mode;
! in2 = gen_unary (NOT, op_mode, op_mode, in2);
! if (GET_CODE (in2) == NOT && GET_CODE (in1) != NOT)
{
rtx tem = in2;
in2 = in1; in1 = tem;
Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/simplify-rtx.c,v
retrieving revision 1.27
diff -c -p -d -r1.27 simplify-rtx.c
*** simplify-rtx.c 2000/09/17 14:33:37 1.27
--- simplify-rtx.c 2000/09/18 18:22:15
*************** simplify_unary_operation (code, mode, op
*** 583,592 ****
aren't constant. */
switch (code)
{
- case NEG:
case NOT:
! /* (not (not X)) == X, similarly for NEG. */
! if (GET_CODE (op) == code)
return XEXP (op, 0);
break;
--- 583,603 ----
aren't constant. */
switch (code)
{
case NOT:
! /* (not (not X)) == X. */
! if (GET_CODE (op) == NOT)
! return XEXP (op, 0);
!
! /* (not (eq X Y)) == (ne X Y), etc. */
! if (mode == BImode && GET_RTX_CLASS (GET_CODE (op)) == '<'
! && can_reverse_comparison_p (op, NULL_RTX))
! return gen_rtx_fmt_ee (reverse_condition (GET_CODE (op)),
! op_mode, XEXP (op, 0), XEXP (op, 1));
! break;
!
! case NEG:
! /* (neg (neg X)) == X. */
! if (GET_CODE (op) == NEG)
return XEXP (op, 0);
break;