Bug 46254 - ICE: in find_reloads, at reload.c:3806 (unable to generate reloads) with -fPIC -mcmodel={medium|large} and __sync_val_compare_and_swap
Summary: ICE: in find_reloads, at reload.c:3806 (unable to generate reloads) with -fPI...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.7.2
Assignee: Uroš Bizjak
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2010-10-31 17:47 UTC by Zdenek Sojka
Modified: 2012-08-28 17:24 UTC (History)
0 users

See Also:
Host:
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail: 4.3.6, 4.4.6, 4.5.2, 4.6.0
Last reconfirmed: 2012-08-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2010-10-31 17:47:31 UTC
----- testcase.c -----
typedef int int128_t __attribute__ ((mode (TI)));
int128_t i;
void foo ()
{
  __sync_val_compare_and_swap (&i, i, i);
}
----------------------

Compiler output - 4.6:
$ gcc -mcx16 -fPIC -mcmodel=large testcase.c
testcase.c: In function 'foo':
testcase.c:6:1: error: unable to generate reloads for:
(insn 17 16 20 2 (parallel [
            (set (reg:TI 0 ax [69])
                (mem/v:TI (reg/f:DI 37 r8 [68]) [-1 S16 A128]))
            (set (mem/v:TI (reg/f:DI 37 r8 [68]) [-1 S16 A128])
                (unspec_volatile:TI [
                        (mem/v:TI (reg/f:DI 37 r8 [68]) [-1 S16 A128])
                        (reg:TI 0 ax [orig:62 i.3 ] [62])
                        (reg:DI 70)
                        (reg:DI 2 cx [71])
                    ] UNSPECV_CMPXCHG))
            (set (reg:CCZ 17 flags)
                (compare:CCZ (unspec_volatile:TI [
                            (mem/v:TI (reg/f:DI 37 r8 [68]) [-1 S16 A128])
                            (reg:TI 0 ax [orig:62 i.3 ] [62])
                            (reg:DI 70)
                            (reg:DI 2 cx [71])
                        ] UNSPECV_CMPXCHG)
                    (reg:TI 0 ax [orig:62 i.3 ] [62])))
        ]) testcase.c:5 2083 {sync_double_compare_and_swapti}
     (expr_list:REG_DEAD (reg:DI 2 cx [71])
        (expr_list:REG_DEAD (reg:DI 70)
            (expr_list:REG_DEAD (reg/f:DI 37 r8 [68])
                (expr_list:REG_DEAD (reg:TI 0 ax [orig:62 i.3 ] [62])
                    (expr_list:REG_UNUSED (reg:TI 0 ax [69])
                        (expr_list:REG_UNUSED (reg:CCZ 17 flags)
                            (nil))))))))
testcase.c:6:1: internal compiler error: in find_reloads, at reload.c:3806
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Compiler output - 4.5:
$ gcc -mcx16 -fPIC -mcmodel=large testcase.c
testcase.c: In function 'foo':
testcase.c:6:1: error: unable to find a register to spill in class 'BREG'
testcase.c:6:1: error: this is the insn:
(insn 17 16 20 2 testcase.c:5 (parallel [
            (set (reg:TI 0 ax [68])
                (mem/v:TI (reg/f:DI 37 r8 [67]) [-1 S16 A0]))
            (set (mem/v:TI (reg/f:DI 37 r8 [67]) [-1 S16 A0])
                (unspec_volatile:TI [
                        (mem/v:TI (reg/f:DI 37 r8 [67]) [-1 S16 A0])
                        (reg:TI 0 ax [orig:61 i.3 ] [61])
                        (reg:DI 69)
                        (reg:DI 2 cx [70])
                    ] 10))
            (set (reg:CCZ 17 flags)
                (compare:CCZ (unspec_volatile:TI [
                            (mem/v:TI (reg/f:DI 37 r8 [67]) [-1 S16 A0])
                            (reg:TI 0 ax [orig:61 i.3 ] [61])
                            (reg:DI 69)
                            (reg:DI 2 cx [70])
                        ] 10)
                    (reg:TI 0 ax [orig:61 i.3 ] [61])))
        ]) 2050 {sync_double_compare_and_swapti} (expr_list:REG_DEAD (reg:DI 2 cx [70])
        (expr_list:REG_DEAD (reg:DI 69)
            (expr_list:REG_DEAD (reg/f:DI 37 r8 [67])
                (expr_list:REG_DEAD (reg:TI 0 ax [orig:61 i.3 ] [61])
                    (expr_list:REG_UNUSED (reg:TI 0 ax [68])
                        (expr_list:REG_UNUSED (reg:CCZ 17 flags)
                            (nil))))))))
testcase.c:6:1: internal compiler error: in spill_failure, at reload1.c:2157
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Compiler output - 4.4:
$ gcc -mcx16 -fPIC -mcmodel=large testcase.c
testcase.c: In function 'foo':
testcase.c:6: error: unable to find a register to spill in class 'BREG'
testcase.c:6: error: this is the insn:
(insn 17 16 25 2 testcase.c:5 (parallel [
            (set (reg:TI 0 ax [68])
                (mem/v:TI (reg/f:DI 37 r8 [67]) [-1 S16 A0]))
            (set (mem/v:TI (reg/f:DI 37 r8 [67]) [-1 S16 A0])
                (unspec_volatile:TI [
                        (mem/v:TI (reg/f:DI 37 r8 [67]) [-1 S16 A0])
                        (reg:TI 0 ax [orig:58 i.3 ] [58])
                        (reg:DI 69)
                        (reg:DI 2 cx [70])
                    ] 10))
            (clobber (reg:CC 17 flags))
        ]) 1993 {sync_double_compare_and_swapti} (expr_list:REG_DEAD (reg:DI 2 cx [70])
        (expr_list:REG_DEAD (reg:DI 69)
            (expr_list:REG_DEAD (reg/f:DI 37 r8 [67])
                (expr_list:REG_DEAD (reg:TI 0 ax [orig:58 i.3 ] [58])
                    (expr_list:REG_UNUSED (reg:TI 0 ax [68])
                        (expr_list:REG_UNUSED (reg:CC 17 flags)
                            (nil))))))))
testcase.c:6: internal compiler error: in spill_failure, at reload1.c:2092
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Tested revisions:
r166105 - crash
4.5 r165781 - crash
4.4 r165754 - crash
4.3.5 - crash
4.2.4 - unimplemented
Comment 1 uros 2012-08-27 21:13:13 UTC
Author: uros
Date: Mon Aug 27 21:13:07 2012
New Revision: 190732

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190732
Log:
	PR target/46254
	* config/i386/predicates.md (cmpxchg8b_pic_memory_operand): Return
	true for TARGET_64BIT or !flag_pic.
	* config/i386/sync.md (*atomic_compare_and_swap_doubledi_pic): Remove.
	(atomic_compare_and_swap_double<mode>): Change operand 2 predicate
	to cmpxchg8b_pic_memory_operand.  Use DWIH mode iterator.
	Add insn constraint.  Conditionally emit xchg asm insns.
	(atomic_compare_and_swap<mode>): Update calls.  Check only
	cmpxchg8b_pic_memory_operand in memory address fixup.
	(DCASMODE): Remove.
	(CASHMODE): Rename from DCASHMODE.
	(doublemodesuffix): Update modes.
	(regprefix): New mode attribute.

	(unspecv) <UNSPECV_CMPXCHG_{1,2,3,4}>: Remove.
	<UNSPECV_CMPXCHG>: New constant.
	(atomic_compare_and_swap<mode>_1): Rename from
	atomic_compare_and_swap_single<mode>.  Update calls and
	unspec_volatile constants.
	(atomic_compare_and_swap<mode>_doubleword): Rename from
	atomic_compare_and_swap_double<mode>.  Update calls and
	unspec_volatile constants.

testsuite/ChangeLog:

	PR target/46254
	* gcc.target/i386/pr46254.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/i386/pr46254.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/predicates.md
    trunk/gcc/config/i386/sync.md
    trunk/gcc/testsuite/ChangeLog
Comment 2 uros 2012-08-28 17:22:18 UTC
Author: uros
Date: Tue Aug 28 17:22:13 2012
New Revision: 190754

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190754
Log:
	Backport from mainline
	2012-08-27  Uros Bizjak  <ubizjak@gmail.com>

	PR target/46254
	* config/i386/predicates.md (cmpxchg8b_pic_memory_operand): Return
	true for TARGET_64BIT or !flag_pic.
	* config/i386/sync.md (*atomic_compare_and_swap_doubledi_pic): Remove.
	(atomic_compare_and_swap_double<mode>): Change operand 2 predicate
	to cmpxchg8b_pic_memory_operand.  Use DWIH mode iterator.
	Add insn constraint.  Conditionally emit xchg asm insns.
	(atomic_compare_and_swap<mode>): Update calls.  Check only
	cmpxchg8b_pic_memory_operand in memory address fixup.
	(DCASMODE): Remove.
	(CASHMODE): Rename from DCASHMODE.
	(doublemodesuffix): Update modes.
	(regprefix): New mode attribute.

	(unspecv) <UNSPECV_CMPXCHG_{1,2,3,4}>: Remove.
	<UNSPECV_CMPXCHG>: New constant.
	(atomic_compare_and_swap<mode>_1): Rename from
	atomic_compare_and_swap_single<mode>.  Update calls and
	unspec_volatile constants.
	(atomic_compare_and_swap<mode>_doubleword): Rename from
	atomic_compare_and_swap_double<mode>.  Update calls and
	unspec_volatile constants.

testsuite/ChangeLog:

	Backport from mainline
	2012-08-27  Uros Bizjak  <ubizjak@gmail.com>

	PR target/46254
	* gcc.target/i386/pr46254.c: New test.


Added:
    branches/gcc-4_7-branch/gcc/testsuite/gcc.target/i386/pr46254.c
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/config/i386/predicates.md
    branches/gcc-4_7-branch/gcc/config/i386/sync.md
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Comment 3 Uroš Bizjak 2012-08-28 17:24:43 UTC
Fixed for 4.7.2+.