Bug 23241 - [3.4/4.0/4.1 Regression] Invalid code generated for comparison of uchar to 255
Summary: [3.4/4.0/4.1 Regression] Invalid code generated for comparison of uchar to 255
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 3.4.5
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on: 19296
Blocks:
  Show dependency treegraph
 
Reported: 2005-08-05 00:14 UTC by Joshua Conner
Modified: 2005-08-08 18:50 UTC (History)
3 users (show)

See Also:
Host:
Target: arm-*-elf
Build:
Known to work: 3.3.5 4.0.2 3.4.5 4.1.0
Known to fail: 3.4.0 4.0.0 3.3.6
Last reconfirmed: 2005-08-05 03:35:24


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Conner 2005-08-05 00:14:42 UTC
The following test code incorrectly generates an assertion failure on gcc mainline and 4.0.1:

#include <assert.h>

struct fbs {
  unsigned char uc8;
} fbs1 = {255};

void testfn ( struct fbs *fbs_ptr )
{
  if ((fbs_ptr->uc8 != 255) && (fbs_ptr->uc8 != 0))
    assert(0);
}

int main (int argc, char *argv[])
{
  testfn (&fbs1);
  return 0;
}
Comment 1 Joshua Conner 2005-08-05 00:17:41 UTC
I believe I have tracked down the root of this behavior to an invalid transformation in simplify_comparison 
(from combine.c).  See email thread starting here:

http://gcc.gnu.org/ml/gcc/2005-08/msg00159.html
Comment 2 Andrew Pinski 2005-08-05 03:35:24 UTC
Confirmed.
Comment 3 Andrew Pinski 2005-08-05 03:40:54 UTC
Just a note for fullness, this was caused by the patch which fixed PR 19296.
Comment 4 Eric Botcazou 2005-08-05 04:46:59 UTC
> Just a note for fullness, this was caused by the patch which fixed PR 19296.

Right.  The annoying thing is that it is in 3.3.6 too so I think someone should
fix the typo on the 3.3 branch too.
Comment 5 Joshua Conner 2005-08-05 16:14:23 UTC
Subject: Re:  [3.4/4.0/4.1 Regression] Invalid code generated for comparison of uchar to 255

> Right.  The annoying thing is that it is in 3.3.6 too so I think  
> someone should
> fix the typo on the 3.3 branch too.

Will do.  Thanks for pointing that out - I would have missed it  
otherwise!

- Josh

Comment 6 CVS Commits 2005-08-08 18:28:54 UTC
Subject: Bug 23241

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jconner@gcc.gnu.org	2005-08-08 18:28:47

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: char-compare.c 

Log message:
	PR rtl-optimization/23241
	* gcc.dg/char-compare.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5894&r2=1.5895
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/char-compare.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 7 CVS Commits 2005-08-08 18:30:29 UTC
Subject: Bug 23241

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jconner@gcc.gnu.org	2005-08-08 18:30:11

Modified files:
	gcc            : ChangeLog combine.c 

Log message:
	PR rtl-optimization/23241
	* combine.c (simplify_comparison): Fix error in determining
	whether to lift a subreg from comparison.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9680&r2=2.9681
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/combine.c.diff?cvsroot=gcc&r1=1.501&r2=1.502

Comment 8 CVS Commits 2005-08-08 18:35:24 UTC
Subject: Bug 23241

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	jconner@gcc.gnu.org	2005-08-08 18:35:14

Modified files:
	gcc            : ChangeLog combine.c 

Log message:
	PR rtl-optimization/23241
	* combine.c (simplify_comparison): Fix error in determining
	whether to lift a subreg from comparison.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.358&r2=2.7592.2.359
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/combine.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.475.4.5&r2=1.475.4.6

Comment 9 CVS Commits 2005-08-08 18:38:07 UTC
Subject: Bug 23241

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	jconner@gcc.gnu.org	2005-08-08 18:37:57

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: char-compare.c 

Log message:
	PR rtl-optimization/23241
	* gcc.dg/char-compare.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.323&r2=1.5084.2.324
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/char-compare.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1

Comment 10 CVS Commits 2005-08-08 18:41:13 UTC
Subject: Bug 23241

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	jconner@gcc.gnu.org	2005-08-08 18:41:07

Modified files:
	gcc            : ChangeLog combine.c 

Log message:
	PR rtl-optimization/23241
	* combine.c (simplify_comparison): Fix error in determining
	whether to lift a subreg from comparison.

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.905&r2=2.2326.2.906
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.14&r2=1.400.4.15

Comment 11 CVS Commits 2005-08-08 18:43:31 UTC
Subject: Bug 23241

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	jconner@gcc.gnu.org	2005-08-08 18:43:11

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: char-compare.c 

Log message:
	PR rtl-optimization/23241
	* gcc.dg/char-compare.c: New test.

Patches:
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.420&r2=1.3389.2.421
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/char-compare.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1

Comment 12 Andrew Pinski 2005-08-08 18:50:29 UTC
Fixed, thanks Josh.
Comment 13 Joseph S. Myers 2006-02-01 00:13:10 UTC
Subject: Bug 23241

Author: jsm28
Date: Wed Feb  1 00:13:07 2006
New Revision: 110456

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110456
Log:
	Backport:
	2005-08-08  Josh Conner  <jconner@apple.com>

	PR rtl-optimization/23241
	* combine.c (simplify_comparison): Fix error in determining
	whether to lift a subreg from comparison.
	* gcc.dg/char-compare.c: New test.

Added:
    branches/csl-3_4_3-linux-branch/gcc/testsuite/gcc.dg/char-compare.c
      - copied unchanged from r110455, branches/gcc-3_4-branch/gcc/testsuite/gcc.dg/char-compare.c
Modified:
    branches/csl-3_4_3-linux-branch/ChangeLog.csl
    branches/csl-3_4_3-linux-branch/gcc/combine.c