Bug 17825 - [3.4 Regression] ICE in reg_bitfield_target_p
Summary: [3.4 Regression] ICE in reg_bitfield_target_p
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.0.0
: P2 critical
Target Milestone: 3.4.4
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2004-10-04 06:59 UTC by Jakub Jelinek
Modified: 2005-03-17 02:04 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-redhat-linux
Build:
Known to work: 4.0.0 3.3
Known to fail: 3.4.3
Last reconfirmed: 2005-02-26 18:50:04


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2004-10-04 06:59:48 UTC
register struct S *b asm ("rbp");
register unsigned int c asm ("rbx");
register unsigned int f asm ("r14");
extern int a;

void foo (int);

struct S
{
  unsigned int h[8];
};

void
bar (void)
{
  unsigned int j, k, l, m;

  j = (f & 0xffff) | ((b->h[2] & 0xffff) << 16);
  k = c & 0xffff;
  if (k == 0)
    {
      foo (0);
    }
  l = (j / k) & 0xffff;
  m = (j % k) & 0xffff;
  f = (f & 0xffff0000) | l;
  b->h[2] = (b->h[2] & 0xffff0000) | m;
}

on x86_64 causes ICE in reg_bitfield_target_p.
try_combine is called on i3:
(insn 33 32 35 2 (set (strict_low_part (subreg:HI (reg/v:SI 43 r14 [ f ]) 0))
        (subreg:HI (reg:SI 68) 0)) 56 {*movstricthi_1} (insn_list:REG_DEP_TRUE 30
(nil))
    (expr_list:REG_DEAD (reg:SI 68)
        (nil)))
and i2:
(insn 30 29 31 2 (parallel [
            (set (reg:SI 68)
                (and:SI (reg:SI 66)
                    (const_int 65535 [0xffff])))
            (clobber (reg:CC 17 flags))
        ]) 289 {*andsi_1} (insn_list:REG_DEP_TRUE 29 (nil))
    (expr_list:REG_DEAD (reg:SI 66)
        (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil))))

but somewhere changes the pattern of i3 into invalid rtl:
(set (strict_low_part (reg:HI 43 r14 [ f ]))
    (subreg:HI (reg:SI 66) 0))

(note missing subreg in the strict_low_part operand).
Works just fine in 3.3, reproduced in 3.4.2 and on HEAD.
Comment 1 Andrew Pinski 2004-10-04 12:49:30 UTC
Confirmed on the mainline.
Comment 2 Mark Mitchell 2004-11-01 00:46:28 UTC
Postponed until GCC 3.4.4.
Comment 5 GCC Commits 2004-11-27 09:39:28 UTC
Subject: Bug 17825

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jakub@gcc.gnu.org	2004-11-27 09:39:01

Modified files:
	gcc            : ChangeLog combine.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/compile: 20041119-1.c 

Log message:
	PR rtl-optimization/17825
	* combine.c (subst): Ignore STRICT_LOW_PART no matter if REG_P (new)
	or not.
	
	* gcc.c-torture/compile/20041119-1.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6580&r2=2.6581
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/combine.c.diff?cvsroot=gcc&r1=1.461&r2=1.462
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4656&r2=1.4657
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/20041119-1.c.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 6 GCC Commits 2005-03-17 01:36:24 UTC
Subject: Bug 17825

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	sayle@gcc.gnu.org	2005-03-17 01:36:15

Modified files:
	gcc            : ChangeLog combine.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/compile: 20041119-1.c 

Log message:
	PR rtl-optimization/17825
	Backport from mainline
	2004-11-27  Jakub Jelinek  <jakub@redhat.com>
	* combine.c (subst): Ignore STRICT_LOW_PART no matter if REG_P (new)
	or not.
	
	PR rtl-optimization/17825
	Backport from mainline
	2004-11-27  Jakub Jelinek  <jakub@redhat.com>
	* gcc.c-torture/compile/20041119-1.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.818&r2=2.2326.2.819
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/combine.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.400.4.13&r2=1.400.4.14
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.370&r2=1.3389.2.371
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/20041119-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.2.28.1

Comment 7 Andrew Pinski 2005-03-17 02:04:44 UTC
Fixed.