Bug 14478 - [3.3 only] rs6000 geu/ltu patterns generate incorrect code
Summary: [3.3 only] rs6000 geu/ltu patterns generate incorrect code
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.1
Assignee: Alan Modra
URL:
Keywords: patch, wrong-code
Depends on:
Blocks:
 
Reported: 2004-03-08 10:00 UTC by Alan Modra
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target: powerpc-linux
Build:
Known to work: tree-ssa 4.0.0 3.4.1
Known to fail: 3.3.3 3.4.0
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Modra 2004-03-08 10:00:03 UTC
Compiling the following with -O results in a function that always returns zero,
instead of one that always returns 1.

int foo (int a, unsigned int x)
{
  unsigned int n = 0;

  while (a)
    x = x + 1, a = a << 1;

  return x >= n;
}
Comment 1 Alan Modra 2004-03-08 10:01:33 UTC
Fixing
Comment 2 Alan Modra 2004-03-08 13:18:06 UTC
Patch here: http://gcc.gnu.org/ml/gcc-patches/2004-03/msg00696.html
Comment 3 Andrew Pinski 2004-03-09 03:41:47 UTC
This is fixed on the tree-ssa because of constant propagation.
Comment 4 Alan Modra 2004-03-09 04:10:22 UTC
Could you perhaps tickle the bug on tree-ssa with a different testcase?

Note that on mainline, the problem insns are generated by combine.
Comment 5 Andrew Pinski 2004-03-09 04:15:34 UTC
You almost cannot as it will constant fold "unsigned >= 0" always before even getting to the RTL.
Comment 6 CVS Commits 2004-03-09 13:39:44 UTC
Subject: Bug 14478

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	hammer-3_3-branch
Changes by:	amodra@gcc.gnu.org	2004-03-09 13:39:41

Modified files:
	gcc            : ChangeLog.hammer 
	gcc/config/rs6000: rs6000.md 

Log message:
	PR target/14478
	* config/rs6000/rs6000.md: Give all reg_or_neg_short_operand
	constraints a zero alternative.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.hammer.diff?cvsroot=gcc&only_with_tag=hammer-3_3-branch&r1=1.1.2.371&r2=1.1.2.372
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.md.diff?cvsroot=gcc&only_with_tag=hammer-3_3-branch&r1=1.221.4.16&r2=1.221.4.17

Comment 7 Andrew Pinski 2004-05-26 12:29:43 UTC
Newest patch to reject the RTL patterns from being made in the first place: <http://gcc.gnu.org/ml/
gcc-patches/2004-05/msg01669.html>
Comment 8 CVS Commits 2004-05-27 07:42:00 UTC
Subject: Bug 14478

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	amodra@gcc.gnu.org	2004-05-27 07:41:53

Modified files:
	gcc            : ChangeLog 
	gcc/config/rs6000: rs6000.c 

Log message:
	PR target/14478
	* config/rs6000/rs6000.c (reg_or_neg_short_operand): Don't allow zero.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.3760&r2=2.3761
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.c.diff?cvsroot=gcc&r1=1.645&r2=1.646

Comment 9 CVS Commits 2004-05-27 07:42:46 UTC
Subject: Bug 14478

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	amodra@gcc.gnu.org	2004-05-27 07:42:29

Modified files:
	gcc            : ChangeLog 
	gcc/config/rs6000: rs6000.c 

Log message:
	PR target/14478
	* config/rs6000/rs6000.c (reg_or_neg_short_operand): Don't allow zero.

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.450&r2=2.2326.2.451
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.576.2.19&r2=1.576.2.20

Comment 10 Alan Modra 2004-05-27 07:45:28 UTC
Fixed on 3.4 and head.