Bug 12028 - [3.4 Regression] powerpc-eabispe produces bad sCOND operation
Summary: [3.4 Regression] powerpc-eabispe produces bad sCOND operation
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.0
: P1 critical
Target Milestone: 3.4.1
Assignee: Aldy Hernandez
Keywords: ice-checking, wrong-code
Depends on:
Reported: 2003-08-21 23:32 UTC by Dara Hazeghi
Modified: 2004-10-30 21:09 UTC (History)
1 user (show)

See Also:
Target: powerpc-eabispe
Known to work: 4.0.0
Known to fail: 3.4.0
Last reconfirmed: 2003-11-29 21:36:53

unreduced testcase (4.92 KB, text/plain)
2003-08-21 23:34 UTC, Dara Hazeghi
Reduced testcase (193 bytes, text/plain)
2003-09-17 13:34 UTC, Zdenek Dvorak

Note You need to log in before you can comment on or make changes to this bug.
Description Dara Hazeghi 2003-08-21 23:32:44 UTC
Building gcc for powerpc-eabispe target on mainline (combined tree):
../combined/configure --target=powerpc-eabispe --enable-languages=c,c++,objc
fails with:
./xgcc -B./ -B/usr/local/powerpc-eabispe/bin/ -isystem /usr/local/powerpc-eabispe/include -
isystem /usr/local/powerpc-eabispe/sys-include -L/home/dara/mainline/objdir/gcc/../ld -O2  -
DIN_GCC -DCROSS_COMPILE   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-
prototypes -isystem ./include   -g  -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -Dinhibit_libc -I. 
-I. -I../../combined/gcc -I../../combined/gcc/. -I../../combined/gcc/config -I../../combined/gcc/
../include   -DL_divdi3 -c ../../combined/gcc/libgcc2.c -fexceptions -fnon-call-exceptions -o 
../../combined/gcc/libgcc2.c: In function `__divdi3':

../../combined/gcc/libgcc2.c:1066: internal compiler error: in ccr_bit, at config/rs6000/
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make[1]: *** [libgcc/./_divdi3.o] Error 1
make[1]: Leaving directory `/home/dara/mainline/objdir/gcc'
make: *** [stmp-multilib] Error 2

The testcase does not ICE if -O1 or lower is specified.
Comment 1 Dara Hazeghi 2003-08-21 23:34:15 UTC
Created attachment 4638 [details]
unreduced testcase

fails with cross cc1 to powerpc-easbispe with -O2 or higher optimization.
Comment 2 Andrew Pinski 2003-08-23 17:25:32 UTC
I think this is a regression from 3.3.
Comment 3 Zdenek Dvorak 2003-09-17 13:34:40 UTC
Created attachment 4774 [details]
Reduced testcase
Comment 4 Andrew Pinski 2003-09-18 06:37:52 UTC
Since  Zdenek reduced this, I am marking as confirmed.
Comment 5 janis187 2003-09-18 20:46:18 UTC
The regression in PR 12028 was introduced or exposed by this patch:

--- gcc/gcc/ChangeLog ---

2003-05-03  Geoffrey Keating  <geoffk@apple.com>

        * config/rs6000/rs6000.c (scc_comparison_operator): Make equivalent
        to branch_positive_comparison_operator.
        (ccr_bit): Check that sCOND conditions are actually a positive bit.
        (print_operand): Remove %D substitution.
        (rs6000_emit_sCOND): Generate complement operation to ensure that
        sCOND input is a positive bit.
        * config/rs6000/rs6000.md: Rearrange sCOND templates to be in the
        same order as bCOND, and add the missing ones.  Remove the %D
        substitutions from the scc patterns.

        * simplify-rtx.c (simplify_relational_operation): Add case for
        ! (fabs(x) < 0.0).


The regression hunt took place on i686-pc-linux-gnu with a cross compiler
for powerpc-eabispe, using the reduced test case from comment #3 with -O2.
Comment 6 Andrew Pinski 2003-11-09 21:41:28 UTC
The problem is part of the patch:
  /* When generating a sCOND operation, only positive conditions are
     allowed.  */
  if (scc_p && code != EQ && code != GT && code != LT && code != UNORDERED
      && code != GTU && code != LTU)
    abort ();
Down below that, there is case for NE (which is the code at this point).
Comment 7 Geoff Keating 2003-11-10 01:01:21 UTC
Subject: Re:  [3.4 Regression] powerpc-eabispe: ICE building __divdi3.o: in ccr_bit, at config/rs6000/rs6000.c:8136

"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

> ------- Additional Comments From pinskia at gcc dot gnu dot org  2003-11-09 21:41 -------
> The problem is part of the patch:
>   /* When generating a sCOND operation, only positive conditions are
>      allowed.  */
>   if (scc_p && code != EQ && code != GT && code != LT && code != UNORDERED
>       && code != GTU && code != LTU)
>     abort ();
> Down below that, there is case for NE (which is the code at this point).

The check is clearly correct.  In the SPE case, both 'EQ' and 'NE' are
'base_bit + 1', but for a sCOND operation the bit must be set when the
condition is true, and EQ and NE are mutually exclusive.  So the
problem must be somewhere else, and removing the check would only
guarantee bad code generation.

Comment 8 Andrew Pinski 2004-02-10 02:00:45 UTC
This was caused by your patch are you going to fix it?
Comment 9 CVS Commits 2004-02-10 03:45:08 UTC
Subject: Bug 12028

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	geoffk@gcc.gnu.org	2004-02-10 03:45:04

Modified files:
	gcc            : ChangeLog 
	gcc/config/rs6000: rs6000.c 

Log message:
	PR 12028
	* config/rs6000/rs6000.c (ccr_bit): Don't let consistency check
	failure stop compilation, just print helpful message.


Comment 10 Geoff Keating 2004-02-10 03:50:40 UTC
The previous patch suppresses the build failure on the 3.4 branch.  However, the underlying problem is 
still there.  I believe it has been there since the e500 port was added.
Comment 11 Andrew Pinski 2004-04-20 14:51:55 UTC
Should be fixed in 3.5.0 by Aldy's rewrite.
Comment 12 Aldy Hernandez 2004-04-29 19:09:16 UTC
Fixed on 3.4 branch by http://gcc.gnu.org/ml/gcc-patches/2004-04/msg01926.html