armel ICE gcc 4.5

Bug #689887 reported by Jani Monoses on 2010-12-13
46
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Linaro GCC
Fix Released
Medium
Richard Sandiford
Linaro GCC Tracking
Fix Committed
Undecided
Unassigned
gcc
Fix Released
Medium
gcc-4.5 (Ubuntu)
Medium
Unassigned
gcc-4.6 (Debian)
Fix Released
Unknown
gcc-4.6 (Ubuntu)
Medium
Unassigned
libisofs (Ubuntu)
Low
Unassigned
traverso (Ubuntu)
High
Unassigned

Bug Description

Binary package hint: gcc-4.5

The traverso package FTBFS on natty because of an ICE

http://launchpadlibrarian.net/60143405/buildlog_ubuntu-natty-armel.traverso_0.49.2-2ubuntu1_FAILEDTOBUILD.txt.gz

Related branches

Jani Monoses (jani) on 2010-12-13
tags: added: armel
Chung-Lin Tang (cltang) wrote :

The ICE looks familiar, can you provide a preprocessed .i file as a testcase? Thanks

Jani Monoses (jani) wrote :

Here is a small program based on the traverso code, that exhibits the error when built with -O2

gcc (Ubuntu/Linaro 4.5.2-1ubuntu2) 4.5.2

internal compiler error: in get_arm_condition_code, at config/arm/arm.c:16985

any of these changes leads to successful build
 - using long instead of 'long long'
 - not using the shift operator
 - not wrapping in a loop

#include <limits.h>

void sample_move_d32u24_sS (char *dst, char *src, unsigned long nsamples, unsigned long dst_skip)

{
        long long y;

        while (nsamples--) {
                y = (long long)(*src) << 8;
                if (y < INT_MIN) {
                        *((int *) dst) = INT_MIN;
                } else {
                        *((int *) dst) = (int)y;
                }
        }
}

Jani Monoses (jani) wrote :

An even smaller testcase

Changing INT_MIN to LONG_LONG_MIN in the conditional fixes the build. (using it this way is arguably a bug in the codebase)

#include <limits.h>

void small(char *dst)

{
        long long y;

        while (1) {
                y = (long long)(*dst) << 8;
                if (y < INT_MIN) {
                        *((int *) dst) = 0;
                } else {
                        *((int *) dst) = 1;
                }
        }
}

Confirmed in gcc-linaro-4.5-2010.12-0:

michaelh@pavo1:~/linaro/bugs$ /tools/toolchains/gcc-linaro-4.5-2010.12-0-armv7l-maverick-cbuild19-pavo4/bin/gcc -O2 -c traverso.c
traverso.c: In function 'small':
traverso.c:16:1: internal compiler error: in get_arm_condition_code, at config/arm/arm.c:16990

The code in question is:

    case CC_NCVmode:
      switch (comp_code)
 {
 case GE: return ARM_GE;
 case LT: return ARM_LT;
 case GEU: return ARM_CS;
 case LTU: return ARM_CC;
 default: gcc_unreachable ();
 }

Michael Hope (michaelh1) on 2011-01-05
Changed in gcc-linaro:
status: New → Triaged
importance: Undecided → Medium
Chung-Lin Tang (cltang) wrote :
Chung-Lin Tang (cltang) on 2011-01-13
Changed in gcc-linaro:
status: Triaged → In Progress
Jani Monoses (jani) wrote :

I see there is no upstream feedback on this. Is this blocking getting it in linaro-gcc as well?

Michael Hope (michaelh1) on 2011-02-17
Changed in gcc-linaro:
assignee: nobody → Chung-Lin Tang (cltang)
Michael Hope (michaelh1) wrote :

Three-week old ping here:
 http://gcc.gnu.org/ml/gcc-patches/2011-01/msg01847.html

Chung-Lin, could you ping this again please?

Chung-Lin Tang (cltang) wrote :

I'll ping again when Richard E. returns.

Jani Monoses (jani) wrote :

ping?

Loïc Minier (lool) wrote :

Also caused libisofs to FTBFS; see bug #742961.

Michael Hope (michaelh1) wrote :

The proposed fixed seems to cause a bootstrap failure when configured with --with-cpu=cortex-a9 --with-fpu=neon. See the merge request.

Chung-Lin Tang (cltang) wrote :

I tried a native bootstrap of upstream trunk with the patch applied, and succeeded.
This is getting more elusive...

Created attachment 24268
preprocessed source

$ ./xgcc -v
Using built-in specs.
COLLECT_GCC=./xgcc
Target: arm-unknown-linux-gnueabi
Configured with: ../configure --target=arm-unknown-linux-gnueabi --prefix=/home/ryan/x-tools/arm-unknown-linux-gnueabi --with-sysroot=/home/ryan/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi//sys-root --disable-multilib --with-local-prefix=/home/ryan/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sys-root --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-c99 --enable-long-long --enable-target-optspace target_alias=arm-unknown-linux-gnueabi --enable-languages=c++ --disable-shared --disable-libmudflap --disable-libssp
Thread model: posix
gcc version 4.7.0 20110517 (experimental) [trunk revision 173832] (GCC)
$ ./xgcc -B. -O1 ~/ice.i
/home/ryan/ice.i: In function 'bar':
/home/ryan/ice.i:33:1: internal compiler error: in get_arm_condition_code, at config/arm/arm.c:17180
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

I haven't been able to reproduce this. Please can you include the args that are being sent to cc1.

With rev173940

$ ./cc1 -fpreprocessed ice.i -quiet -O1
ice.i: In function 'bar':
ice.i:33:1: internal compiler error: in get_arm_condition_code, at config/arm/arm.c:17021
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

I was hoping the compiler command would tell me what -mcpu it was defaulting to.

Anyway, I have managed to reproduce it now, by compiling as follows:

  cc1 -fpreprocessed 49030.i -quiet -O1 -o 49030.s -mcpu=arm7tdmi -marm

Note that it all works with -mthumb and/or -mcpu=cortex-a9.

I have tried this with my old toolchain and it is broken as far back as r164700.

(In reply to comment #3)
> I was hoping the compiler command would tell me what -mcpu it was defaulting
> to.

I'm using an arm-unknown-linux-gnueabi configuration which defaults an arm10tdmi.

linux-eabi.h:#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm10tdmi

Michael Hope (michaelh1) wrote :

For reference, this test fails in gcc-linaro-{4.5,4.6}-2011.05-0, and gcc trunk r174795.

It succeeds in gcc-4.6.0 and gcc-4.5.3.

All 4.4 based compilers are fine.

Michael Hope (michaelh1) wrote :

The work-around is to compile at -O0 or -O3. -O1 and -O2 fail.

The same assert is seen in https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/689887 in Thumb-2 mode on trunk r174795.

Chung-Lin posted a patch at http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00790.html but there are bootstrap issues.

Adding -fno-if-conversion works around the problem.

Michael Hope (michaelh1) wrote :

Adding -fno-if-conversion works around the problem.

In , Mikpe (mikpe) wrote :

It's caused by r161764:

Author: sandra
Date: Sat Jul 3 01:00:37 2010
New Revision: 161764

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161764
Log:
2010-07-02 Daniel Jacobowitz <email address hidden>
     Julian Brown <email address hidden>
     Sandra Loosemore <email address hidden>

 gcc/
 * config/arm/arm.c (arm_canonicalize_comparison): Canonicalize DImode
 comparisons. Adjust to take both operands.
 (arm_select_cc_mode): Handle DImode comparisons.
 (arm_gen_compare_reg): Generate a scratch register for DImode
 comparisons which require one. Use xor for Thumb equality checks.
 (arm_const_double_by_immediates): New.
 (arm_print_operand): Allow 'Q' and 'R' for constants.
 (get_arm_condition_code): Handle new CC_CZmode and CC_NCVmode.
        ...

In , Mikpe (mikpe) wrote :

Created attachment 24503
more reduced test case, ICEs at -O1 for armv5te and armv6

Using this slightly more reduced test case I've found that gcc transforms

(set (reg:CC_NCV ...) (compare:CC_NCV (reg:DI ...) (const_int 1 ...)))
(if_then_else (ge (reg:CC_NCV ...) ...) ...)

to

(set (reg:CC_NCV ...) (compare:CC_NCV (reg:DI ...) (const_int 0 ...)))
(if_then_else (gt (reg:CC_NCV ...) ...)

because ifcvt calls noce_get_condition which calls canonicalize_condition, and the latter has a general rule to transform (GE x const) to (GT x const-1).

So the careful code in e.g. cbranchdi4 to not generate unimplemented comparisons is neutralized by generic code.

Do DImode comparisons really have to be asymmetric? I.e., could CC_NCV be removed? I see that LT is apparently supported so why can't GT be too?

In , Mikpe (mikpe) wrote :

I have a preliminary patch which creates a clone of *arm_cmpdi_insn that does a reverse comparison, via a new CC mode for must-be-reversed comparisons, and corresponding updates to arm_select_cc_mode and get_arm_condition_code. It's the same transformation from eg (GT x y) to (LT y x) that cstoredi4 does, only later so it can handle problematic comparisons introduced by the middle-end.

This fixes the ICEs on the two test cases in this PR. I'll do a full bootstrap and regtest as soon as my test machine is done with its current bootstrap and regtest cycle.

I'll send the FSF Yet Another Ping about my employer's copyright disclaimer first thing tomorrow. They've had the papers since January or February...

Michael Hope (michaelh1) wrote :

Note that Mikael Pettersson has a patch against the upstream ticket but has copyright assignment issues.

Changed in gcc-linaro:
status: In Progress → Triaged
assignee: Chung-Lin Tang (cltang) → nobody
Matthias Klose (doko) on 2011-07-15
Changed in gcc-4.5 (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
Changed in gcc-4.6 (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
Changed in gcc-4.6 (Debian):
status: Unknown → Confirmed
Changed in gcc-linaro:
assignee: nobody → Richard Sandiford (rsandifo)
Changed in gcc:
importance: Unknown → Medium
status: Unknown → Confirmed

Author: rsandifo
Date: Wed Sep 7 13:48:03 2011
New Revision: 178636

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178636
Log:
gcc/
 PR target/49030
 * config/arm/arm-protos.h (maybe_get_arm_condition_code): Declare.
 * config/arm/arm.c (maybe_get_arm_condition_code): New function,
 reusing the old code from get_arm_condition_code. Return ARM_NV
 for invalid comparison codes.
 (get_arm_condition_code): Redefine in terms of
 maybe_get_arm_condition_code.
 * config/arm/predicates.md (arm_comparison_operator): Use
 maybe_get_arm_condition_code.

gcc/testsuite/
 PR target/49030
 * gcc.dg/torture/pr49030.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr49030.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm-protos.h
    trunk/gcc/config/arm/arm.c
    trunk/gcc/config/arm/predicates.md
    trunk/gcc/testsuite/ChangeLog

I am out of the office until September 19th. For emergencies please contact Fred Plante.

Michael Hope (michaelh1) on 2011-09-08
Changed in gcc-linaro:
milestone: none → 4.6-2011.09
status: Triaged → In Progress
In , Gjl (gjl) wrote :

Author: gjl
Date: Fri Sep 9 17:00:26 2011
New Revision: 178736

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178736
Log:
 PR target/49030
 * gcc.dg/torture/pr49030.c: Run only if target int32plus.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/torture/pr49030.c

Michael Hope (michaelh1) wrote :

Confirmed that the fix fixes the original test case.

Changed in gcc-linaro:
status: In Progress → Fix Committed
Michael Hope (michaelh1) wrote :

The fix was reverted due to LP: #850099

Changed in gcc-linaro:
status: Fix Committed → In Progress
milestone: 4.6-2011.09 → 4.6-2011.10
Matthias Klose (doko) on 2011-09-27
tags: added: ftbfs oneiric
Changed in traverso (Ubuntu):
importance: Undecided → High
status: New → Confirmed
Michael Hope (michaelh1) wrote :

Note the follow on patch that fixes LP: #850099 is here:
 http://gcc.gnu.org/ml/gcc-patches/2011-09/msg01128.html

Richard will be backporting both to gcc-linaro in due course.

Michael Hope (michaelh1) on 2011-10-10
Changed in gcc-linaro:
status: In Progress → Fix Committed
Loïc Minier (lool) wrote :

Once the gcc-linaro fix lands in Ubuntu, we should revert the -O0 workaround in libisofs and retry a traverso build.

Changed in libisofs (Ubuntu):
status: New → Confirmed
importance: Undecided → Low
Michael Hope (michaelh1) on 2011-10-13
Changed in gcc-linaro:
status: Fix Committed → Fix Released
Matthias Klose (doko) wrote :

won't fix anymore in 4.5

Changed in gcc-4.5 (Ubuntu):
status: Triaged → Won't Fix
Matthias Klose (doko) wrote :

fixed in gcc-4.6 (precise)

Changed in gcc-4.6 (Ubuntu):
status: Triaged → Fix Released
Matthias Klose (doko) wrote :

traverso did build in precise

Changed in traverso (Ubuntu):
status: Confirmed → Fix Released
Matthias Klose (doko) wrote :

libisofs 1.1.6-1ubuntu1 built in precise without work-around

Changed in libisofs (Ubuntu):
status: Confirmed → Fix Released
Changed in gcc-4.6 (Debian):
status: Confirmed → Fix Released

Fixed on trunk, and not marked as a regression.

Changed in gcc:
status: Confirmed → Fix Released
Changed in gcc-linaro-tracking:
milestone: none → 4.7.0
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.