This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Allow 'else' case in noce_try_addcc (ifcvt.c)
- From: "Ulrich Weigand" <weigand at i1 dot informatik dot uni-erlangen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 15 Oct 2003 00:19:55 +0200 (CEST)
- Subject: [PATCH] Allow 'else' case in noce_try_addcc (ifcvt.c)
Hello,
this patch generalizes noce_try_addcc (ifcvt.c) to allow
'else' cases. The reason for this that it apparently often
happens that gcse transforms
x = a;
if (test)
x++;
into
x = a;
if (test)
x = a + 1;
which is interpreted by ifcvt as
if (test)
x = a + 1;
else
x = a;
and thus refused by the current noce_try_addcc implementation.
Fortunately this appears to be trivial to fix by just removing
the check for 'if_info->b == if_info->x' and fixing up a couple
of places where 'x' and 'b' had been used interchangably.
Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux
(together with a backend patch that actually adds an addsicc
insn pattern ...).
OK?
Bye,
Ulrich
ChangeLog:
* ifcvt.c (noce_try_addcc): Handle ifs with 'else' case.
Index: gcc/ifcvt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ifcvt.c,v
retrieving revision 1.125
diff -c -p -r1.125 ifcvt.c
*** gcc/ifcvt.c 15 Sep 2003 01:55:50 -0000 1.125
--- gcc/ifcvt.c 28 Sep 2003 19:26:53 -0000
*************** noce_try_addcc (struct noce_if_info *if_
*** 884,893 ****
int subtract, normalize;
if (! no_new_pseudos
- /* Should be no `else' case to worry about. */
- && if_info->b == if_info->x
&& GET_CODE (if_info->a) == PLUS
! && rtx_equal_p (XEXP (if_info->a, 0), if_info->x)
&& (reversed_comparison_code (if_info->cond, if_info->jump)
!= UNKNOWN))
{
--- 884,891 ----
int subtract, normalize;
if (! no_new_pseudos
&& GET_CODE (if_info->a) == PLUS
! && rtx_equal_p (XEXP (if_info->a, 0), if_info->b)
&& (reversed_comparison_code (if_info->cond, if_info->jump)
!= UNKNOWN))
{
*************** noce_try_addcc (struct noce_if_info *if_
*** 942,948 ****
if (target)
target = expand_simple_binop (GET_MODE (if_info->x),
subtract ? MINUS : PLUS,
! if_info->x, target, if_info->x,
0, OPTAB_WIDEN);
if (target)
{
--- 940,946 ----
if (target)
target = expand_simple_binop (GET_MODE (if_info->x),
subtract ? MINUS : PLUS,
! if_info->b, target, if_info->x,
0, OPTAB_WIDEN);
if (target)
{
--
Dr. Ulrich Weigand
weigand@informatik.uni-erlangen.de