Bug 24315 – [3.4 Regression] amd64 fails -fpeephole2

Description Doug Coleman 2005-10-11 18:57:55 UTC

native/s48_bignum.c:456: internal compiler error: in final_scan_insn, at final.c:2514
Please submit a full bug report,

I'm still looking for where to attach my .i file.  Hopefully I can attach it after submitting this page.
uname -a:
Linux frogger 2.6.12-9-amd64-generic #1 Tue Oct 4 19:23:45 BST 2005 x86_64 GNU/Linux

gcc --version:
gcc (GCC) 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)

Comment 2 Andrew Pinski 2005-10-11 19:00:03 UTC

Oh, can you show the command line invokation of gcc?

Comment 3 Doug Coleman 2005-10-11 19:03:00 UTC

gcc -fpeephole2 s48_bignum.i

Thanks!

Comment 4 Andrew Pinski 2005-10-11 19:05:25 UTC

(In reply to comment #2)
> Oh, can you show the command line invokation of gcc?
Never mind, -O0 -fpeephole2 makes it fail.

Comment 5 Andrew Pinski 2005-10-11 19:28:46 UTC

Reduced testcase for 4.0.x and above:
void s48_double_to_bignum(int exponent){
     long length = ((((exponent) + ((((sizeof (long)) * 8) - 2) - 1)) / (((sizeof (long)) * 8) - 2)));
   }

This really should be filed in a different PR as that one is a regression.

I will try to get a reduced testcase for 3.4.x and 3.3.x later today.

Comment 6 Andrew Pinski 2005-10-12 13:30:41 UTC

Here is the one for 3.3.3 and above:
typedef long bignum_digit_type;
void bignum_divide_unsigned_normalized( ){
bignum_digit_type guess;
guess = ((((unsigned long) 1) << (((sizeof (bignum_digit_type)) * 8) - 2)) - 1);
}

I will file the other one seperate now.

Comment 8 Andrew Pinski 2005-10-12 13:42:21 UTC

Confirmed that this is a real regression.

Comment 9 Andrew Pinski 2005-10-12 13:45:19 UTC

The instruction we are should have split earlier:
(insn/v 8 21 26 (set (mem/c/i:DI (plus:DI (reg/f:DI 6 bp)
                (const_int -8 [0xfffffffffffffff8])) [0 guess+0 S8 A64])
        (const_int 4611686018427387903 [0x3fffffffffffffff])) 81 {*movdi_1_rex64} (nil)
    (nil))

Comment 10 Andrew Pinski 2005-10-12 13:46:49 UTC

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

Comment 11 Andrew Pinski 2005-10-12 13:48:42 UTC

It turned out the one in comment #5 is the same issue as the orginal bug too.

Comment 13 Uroš Bizjak 2005-10-17 07:21:18 UTC

Fixed on mainline.

The bugfix is really trivial to fix, but I don't have older branches installed here. Could somebody help me with a backports?
Subject: Bug 24315

Author: uros
Date: Tue Nov  8 07:58:51 2005
New Revision: 106633

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106633
Log:
	PR target/19340
	* reg-stack.c (reg_to_stack): Update register liveness also
	for flag_sched2_use_traces.

	PR target/24315
	* config/i386/i386.md (*pushdi2_rex64 splitter)
	(*movdi_1_rex64 splitter, *ashldi3_1 splitter)
	(*ashrdi3_1 splitter, *lshrdi3_1 splitter): Delay splitting after
	flow2 pass only when (optimize > 0 && flag_peephole2).

testsuite/

	PR target/19340
	* gcc.dg/pr19340.c: New test.

	PR target/24315
	* gcc.target/i386/pr24315.c: New test.


Added:
    branches/gcc-4_0-branch/gcc/testsuite/gcc.dg/pr19340.c
    branches/gcc-4_0-branch/gcc/testsuite/gcc.target/i386/pr24315.c
Modified:
    branches/gcc-4_0-branch/gcc/ChangeLog
    branches/gcc-4_0-branch/gcc/config/i386/i386.md
    branches/gcc-4_0-branch/gcc/reg-stack.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog

Comment 15 Paolo Bonzini 2005-11-08 08:19:45 UTC

now fixed on 4.0 branch too
Subject: Bug 24315

Author: uros
Date: Thu Nov 10 07:27:47 2005
New Revision: 106728

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106728
Log:
        PR target/24315
        * config/i386/i386.md (*pushdi2_rex64 splitter)
        (*movdi_1_rex64 splitter): Delay splitting after
        flow2 pass only when (optimize > 0 && flag_peephole2).

	PR target/19340
	* reg-stack.c (reg_to_stack): Update register liveness also
	for flag_sched2_use_traces.

testsuite/

        PR target/24315
        * gcc.dg/pr24315.c: New test.

        PR target/19340
        * gcc.dg/pr19340.c: New test.


Added:
    branches/gcc-3_4-branch/gcc/testsuite/gcc.dg/pr19340.c
      - copied unchanged from r106632, trunk/gcc/testsuite/gcc.dg/pr19340.c
    branches/gcc-3_4-branch/gcc/testsuite/gcc.dg/pr24315.c
Modified:
    branches/gcc-3_4-branch/gcc/ChangeLog
    branches/gcc-3_4-branch/gcc/config/i386/i386.md
    branches/gcc-3_4-branch/gcc/reg-stack.c
    branches/gcc-3_4-branch/gcc/testsuite/ChangeLog

Comment 17 Uroš Bizjak 2005-11-10 07:31:55 UTC

Fixed on 3.4 branch.