Bug 37014 - [4.2/4.3/4.4 Regression] internal compiler error: in expand_expr_real_1, at expr.c:8760
Summary: [4.2/4.3/4.4 Regression] internal compiler error: in expand_expr_real_1, at e...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.2.4
: P1 normal
Target Milestone: 4.3.3
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2008-08-03 08:41 UTC by Alexandros C. Couloumbis
Modified: 2009-04-29 15:15 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.0
Known to fail: 4.1.0 4.2.0 4.3.0 4.4.0
Last reconfirmed: 2008-08-12 10:01:22


Attachments
hw.i.gz (248.13 KB, application/octet-stream)
2008-08-05 15:59 UTC, Adrian Bunk
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandros C. Couloumbis 2008-08-03 08:41:10 UTC
trying to compile ath9k for mips or mipsel under openwrt toolchain with
gcc-4.2.4 produces the following error:

make[3]: Entering directory `/extra3/openwrt/ar71xx/trunk/package/ath9k'
make -C "/extra3/openwrt/ar71xx/trunk/build_dir/linux-ar71xx/linux-2.6.26"
ARCH="mips" CROSS_COMPILE="mips-linux-uclibc-"
SUBDIRS="/extra3/openwrt/ar71xx/trunk/build_dir/linux-ar71xx/ath9k-20080731/drivers/net/wireless/ath9k"
EXTRA_CFLAGS=" -DCONFIG_ATH9K=1  "
LINUXINCLUDE="-I/extra3/openwrt/ar71xx/trunk/staging_dir/mips/usr/include/mac80211
-I/extra3/openwrt/ar71xx/trunk/build_dir/linux-ar71xx/linux-2.6.26/include
-include linux/autoconf.h" CONFIG_ATH9K=m modules
make[4]: Entering directory
`/extra3/openwrt/ar71xx/trunk/build_dir/linux-ar71xx/linux-2.6.26'
  CC [M] 
/extra3/openwrt/ar71xx/trunk/build_dir/linux-ar71xx/ath9k-20080731/drivers/net/wireless/ath9k/hw.o
/extra3/openwrt/ar71xx/trunk/build_dir/linux-ar71xx/ath9k-20080731/drivers/net/wireless/ath9k/hw.c:
In function 'ath9k_hw_spur_mitigate':
/extra3/openwrt/ar71xx/trunk/build_dir/linux-ar71xx/ath9k-20080731/drivers/net/wireless/ath9k/hw.c:4906:
internal compiler error: in expand_expr_real_1, at expr.c:8760
Please submit a full bug report,
with preprocessed source if appropriate.

a snapshot of the ath9k used is here:
http://wifi.ozo.com/airo/openwrt/source/ath9k

a relative ticket on the ath9k is here:
https://lists.ath9k.org/pipermail/ath9k-devel/2008-August/000082.html

gcc-3.4.6 compiles fine for mips & mipsel targets. gcc-4.2.4 also compiles fine
for x86 target.
Comment 1 Adrian Bunk 2008-08-05 15:56:07 UTC
Stephen Rothwell reported that he also saw it on powerpc.

I verified the bug on powerpc with the following gcc versions:
- 4.2.4
- 4.3, latest svn
- 4.4, latest svn

4.1.2 is fine.
Comment 2 Adrian Bunk 2008-08-05 15:59:15 UTC
Created attachment 16025 [details]
hw.i.gz

$ powerpc64-linux-gcc --version
powerpc64-linux-gcc (GCC) 4.4.0 20080805 (experimental)
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ powerpc64-linux-gcc -O1 hw.i
/TMP/git/linux-next/drivers/net/wireless/ath9k/hw.c: In function 'ath9k_hw_9280_spur_mitigate':
/TMP/git/linux-next/drivers/net/wireless/ath9k/hw.c:4660: internal compiler error: in expand_expr_real_1, at expr.c:9176
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
$
Comment 3 Andrew Pinski 2008-08-05 17:11:46 UTC
Reducing for PPC-linux-gnu.
Comment 4 Andrew Pinski 2008-08-05 18:03:10 UTC
Reduced testcase:
void ath9k_hw_9280_spur_mitigate( int bin, int cur_vit_mask) {
  int i;
  signed char mask_m[123];
  signed char mask_p[123];
  signed char mask_amt;
  for (i = 0; i < 123;i++)
  {
    int __x1 = ({int __x = cur_vit_mask - bin;(__x < 0) ? -__x : __x;});
    mask_amt =  __x1< 75;
    mask_m[cur_vit_mask ] = mask_amt;
    mask_p[cur_vit_mask] = mask_amt;
    cur_vit_mask --;
  }
  f(mask_p);
  f(mask_m);
}

Expand is getting:
(int) ivtmp.20 >= -74 && (int) ivtmp.20 <= 74

Which comes from folding of:
ABS_EXPR <(int) ivtmp.20> <= 74

Which is folded at:
4509              exp = fold_convert (lang_hooks.types.type_for_mode
4510                                    (GET_MODE (SUBREG_REG (target)),
4511                                     SUBREG_PROMOTED_UNSIGNED_P (target)),
4512                                  exp);

Comment 5 Andrew Pinski 2008-08-05 18:07:06 UTC
This worked for at least 3.4.0 as this tree was able to be expanded :).
Comment 6 Mikael Pettersson 2008-08-08 13:58:42 UTC
(In reply to comment #4)
I can confirm that the reduced test case fails for me with gcc 4.0.4, 4.1.2, 4.2.4, and 4.3.1 on both powerpc and powerpc64. gcc-3.4.6 and older work.

It doesn't fail for me with gcc-4.x on either sparc64 or arm.
Comment 7 Jakub Jelinek 2008-08-11 18:38:31 UTC
I think the options are:
1) handle TRUTH_{AND,OR}IF_EXPR in expand_expr again (revert part of Paolo's
   2004-08-09 expr.c "dead" code removals) - while these aren't present
   in GIMPLE nor can be created by TER, they can be created by folding during
   expansion.  Maybe even COMPOUND_EXPR could be handled there and all the
   ugly hacks builtins.c does to work around this could be removed.
2) have a special flag for fold-const.c, set during expansion, that would
   preclude certain kinds of folding (e.g. creation of the trees that aren't
   handled by the expander)
3) have expand's special versions of the various fold* routines, look for the
   unhandled trees in what it creates and either fail to fold them, or transform
   to something else.

IMHO 1) would be probably easiest to implement, 3) too ugly to live, 2) possible.
Comment 8 Jakub Jelinek 2008-08-12 18:07:04 UTC
Subject: Bug 37014

Author: jakub
Date: Tue Aug 12 18:05:43 2008
New Revision: 139029

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139029
Log:
	PR middle-end/37014
	* expr.c (expand_expr_real_1): Handle TRUTH_ANDIF_EXPR
	and TRUTH_ORIF_EXPR.
	* dojump.c (do_jump): Likewise.

	* gcc.c-torture/compile/20080812-1.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/20080812-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dojump.c
    trunk/gcc/expr.c
    trunk/gcc/testsuite/ChangeLog

Comment 9 Jakub Jelinek 2008-08-12 18:37:48 UTC
Subject: Bug 37014

Author: jakub
Date: Tue Aug 12 18:36:28 2008
New Revision: 139032

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139032
Log:
	PR middle-end/37014
	* expr.c (expand_expr_real_1): Handle TRUTH_ANDIF_EXPR
	and TRUTH_ORIF_EXPR.
	* dojump.c (do_jump): Likewise.

	* gcc.c-torture/compile/20080812-1.c: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.c-torture/compile/20080812-1.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/dojump.c
    branches/gcc-4_3-branch/gcc/expr.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 10 Jakub Jelinek 2008-08-13 08:20:42 UTC
Fixed.