ICE on a | (b << negative-constant)

Bug #836401 reported by Michael Hope
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro GCC
Fix Released
High
Andrew Stubbs
4.6
Fix Released
High
Andrew Stubbs
4.6-2011.07-stable
Won't Fix
High
Michael Hope
Linaro GCC Tracking
Fix Committed
Undecided
Unassigned
gcc
Fix Released
Medium
gcc-4.6 (Debian)
Fix Released
Unknown

Bug Description

See the upstream bug for more. Appears when building libvorbis and llvm.

Related branches

Revision history for this message
In , Michael Hope (michaelh1) wrote :

trunk r178025, 4.6.1, and 4.5.3 all ICE with unsatisfied constraints on the following code:

int foo(int a, int b)
{
    return a | (b << -3);
}

shift.c: In function 'foo':
shift.c:3:5: warning: left shift count is negative [enabled by default]
shift.c:4:1: error: insn does not satisfy its constraints:
(insn 14 9 17 2 (set (reg/i:SI 0 r0)
        (ior:SI (ashift:SI (reg:SI 1 r1 [ b ])
                (const_int -3 [0xfffffffffffffffd]))
            (reg:SI 0 r0 [ a ]))) shift.c:4 259 {*arith_shiftsi}
     (expr_list:REG_DEAD (reg:SI 1 r1 [ b ])
        (nil)))
shift.c:4:1: internal compiler error: in extract_constrain_insn_cached, at recog.c:2030

This happens with -mcpu=cortex-a9 -mthumb. With -marm, GCC recognises that the shift is unusual, loads it into a register, then uses this in the register-shifted-register form of ORR. This form isn't available in Thumb-2.

The problem was originally seen in libtheora:lib/mathops.c when built with -O3 -funroll-loops when a shift by negative 8 is generated.

Revision history for this message
In , Michael Hope (michaelh1) wrote :

Also occurs when building LLVM trunk. See:
 http://builds.linaro.org/toolchain/llvm-3.0~svn138625/logs/armv7l-natty-cbuild172-ursa1-cortexa9r1/llvm-build.txt

/scratch/cbuild/slave/slaves/ursa1/llvm-3.0~svn138625/llvm/llvm-3.0~/tools/clang/unittests/AST/APValueTest.cpp: In member function 'virtual void {anonymous}::APValue_Diagnostics_Test::TestBody()':
/scratch/cbuild/slave/slaves/ursa1/llvm-3.0~svn138625/llvm/llvm-3.0~/tools/clang/unittests/AST/APValueTest.cpp:77:1: error: insn does not satisfy its constraints:
(insn 1267 1266 1269 72 (set (subreg:SI (reg:DI 1327) 0)
        (ior:SI (ashift:SI (reg:SI 1330)
                (const_int -16 [0xfffffffffffffff0]))
            (subreg:SI (reg:DI 1327) 0))) /scratch/cbuild/slave/slaves/ursa1/llvm-3.0~svn138625/llvm/llvm-3.0~/include/llvm/ADT/APInt.h:140 257 {*arith_shiftsi}
     (nil))
/scratch/cbuild/slave/slaves/ursa1/llvm-3.0~svn138625/llvm/llvm-3.0~/tools/clang/unittests/AST/APValueTest.cpp:77:1: internal compiler error: in extract_constrain_insn_cached, at recog.c:2028

Changed in gcc:
importance: Unknown → Medium
status: Unknown → New
Michael Hope (michaelh1)
Changed in gcc-linaro:
assignee: nobody → Andrew Stubbs (ams-codesourcery)
Revision history for this message
In , Andrew Stubbs (ams-codesourcery) wrote :

The problem appears to be that the predicate accepts any constant, without checking the range.

I'll post a patch shortly.

Changed in gcc:
status: New → In Progress
Michael Hope (michaelh1)
Changed in gcc-linaro:
status: Triaged → In Progress
milestone: none → 4.6-2011.09
Revision history for this message
Michael Hope (michaelh1) wrote :

Confirmed that the fix works.

Changed in gcc-linaro:
status: In Progress → Fix Committed
Revision history for this message
Michael Hope (michaelh1) wrote :

...against the testcase. Upstream discussion is ongoing.

Michael Hope (michaelh1)
Changed in gcc-linaro:
status: Fix Committed → Fix Released
Revision history for this message
In , Andrew Stubbs (ams-codesourcery) wrote :

This has now been fixed. The patch was posted here:

http://gcc.gnu.org/ml/gcc-patches/2011-10/msg00594.html

Changed in gcc:
status: In Progress → Fix Released
Revision history for this message
In , Doko-v (doko-v) wrote :

*** Bug 50947 has been marked as a duplicate of this bug. ***

Changed in gcc-4.6 (Debian):
status: Unknown → Confirmed
Changed in gcc-4.6 (Debian):
status: Confirmed → Fix Released
Revision history for this message
Andrew Stubbs (ams-codesourcery) wrote :

This patch was rejected upstream:
Related: lp:gcc-linaro/4.6,revno=106804

This is the backport of the final patch, and reverts the previous commit:
Related: lp:gcc-linaro/4.6,revno=106825

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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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