Bug 57860 - wrong code for bitwise ops with long long literal on x86_64-linux (32-bit mode)
Summary: wrong code for bitwise ops with long long literal on x86_64-linux (32-bit mode)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-09 08:20 UTC by Zhendong Su
Modified: 2013-08-27 09:27 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhendong Su 2013-07-09 08:20:26 UTC
The current gcc trunk mis-compiles the following code on x86_64-linux at -O2 and -O3 in 32-bit mode. This is a regression from 4.8.x. 

$ gcc-trunk -v
gcc version 4.9.0 20130708 (experimental) [trunk revision 200751] (GCC) 
$ gcc-trunk -m32 -O2 reduced.c
$ a.out
0
$ gcc-trunk -m32 -O3 reduced.c
$ a.out
0
$ gcc-trunk -m32 -O0 reduced.c
$ a.out
1
$ gcc-4.8 -m32 -O2 reduced.c
$ a.out
1
$ 


--------------------------------------------


int printf (const char *, ...);

int a, *b = &a, c, d, e, *f = &e, g, *h = &d, k[1] = {1};

int
foo (int p)
{
  for (;; g++)
    {
      for (; c; c--);
      *f = *h = p > ((0x1FFFFFFFFLL ^ a) & *b);
      if (k[g])
	return 0;
    }
}

int
main ()
{
  foo (1);
  printf ("%d\n", d);
  return 0;
}
Comment 1 Mikael Pettersson 2013-07-10 13:06:47 UTC
Caused by the LRA changes in r200723.  Author CCd.
Comment 2 Jakub Jelinek 2013-08-27 09:16:58 UTC
This was introduced with r200723 and got fixed in r200899.
Comment 3 Jakub Jelinek 2013-08-27 09:27:07 UTC
Author: jakub
Date: Tue Aug 27 09:24:52 2013
New Revision: 202018

URL: http://gcc.gnu.org/viewcvs?rev=202018&root=gcc&view=rev
Log:
	PR rtl-optimization/57860
	PR rtl-optimization/57861
	PR rtl-optimization/57875
	PR rtl-optimization/57876
	PR rtl-optimization/57877
	* gcc.c-torture/execute/pr57860.c: New test.
	* gcc.c-torture/execute/pr57861.c: New test.
	* gcc.c-torture/execute/pr57875.c: New test.
	* gcc.c-torture/execute/pr57876.c: New test.
	* gcc.c-torture/execute/pr57877.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr57860.c
    trunk/gcc/testsuite/gcc.c-torture/execute/pr57861.c
    trunk/gcc/testsuite/gcc.c-torture/execute/pr57875.c
    trunk/gcc/testsuite/gcc.c-torture/execute/pr57876.c
    trunk/gcc/testsuite/gcc.c-torture/execute/pr57877.c
Modified:
    trunk/gcc/testsuite/ChangeLog