This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
MIPS patch: fix incorrectly inverted branch
- To: gcc-patches at gcc dot gnu dot org
- Subject: MIPS patch: fix incorrectly inverted branch
- From: Richard Sandiford <r dot sandiford at redhat dot com>
- Date: 22 Jun 2001 15:37:42 +0100
Testcase: attached
Target: mips64-elf -mips3
This patch fixes a problem with gen_int_relational's handling of X != 0
comparisons, where X is not a register. When called by branch-generating
functions, gen_int_relational is passed a pointer to a boolean flag that
gets set if the branch should be reversed. In the case of X != 0,
gen_int_relational first assumes it will generate an inverted condition, and
that a reversed branch is therefore needed. It later realises it can create
a non-inverted condition after all, but doesn't change its decision to
reverse the branch. In the test case below, the "then" and "else" clauses
are effectively reversed.
Patch was tested on a i686-linux-gnu-x-mips64-elf toolchain with -mips3.
Fixes the test case below & introduces no regressions.
2001-06-22 Richard Sandiford <rsandifo@redhat.com>
* config/mips/mips.c (gen_int_relational): Tell the caller not to
reverse a branch if a NE comparison is implemented with GTU.
Index: mips.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.c,v
retrieving revision 1.117
diff -c -p -d -r1.117 mips.c
*** mips.c 2001/05/31 19:39:30 1.117
--- mips.c 2001/06/22 13:41:15
*************** gen_int_relational (test_code, result, c
*** 2965,2971 ****
if (! TARGET_MIPS16)
{
convert_move (result, gen_rtx (GTU, mode, reg, const0_rtx), 0);
! invert = 0;
}
else
{
--- 2965,2974 ----
if (! TARGET_MIPS16)
{
convert_move (result, gen_rtx (GTU, mode, reg, const0_rtx), 0);
! if (p_invert != NULL)
! *p_invert = 0;
! else
! invert = 0;
}
else
{
Test case:
void foo (int *a) {}
int main ()
{
int a;
if (&a == 0)
abort ();
else
{
foo (&a);
exit (0);
}
}