Bug 28755 - [4.2 Regression] duplicate members of arrays
Summary: [4.2 Regression] duplicate members of arrays
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.1
: P2 normal
Target Milestone: 4.3.0
Assignee: Jakub Jelinek
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: missed-optimization, patch
Depends on:
Blocks: 28779
  Show dependency treegraph
 
Reported: 2006-08-16 17:28 UTC by David Woodhouse
Modified: 2009-03-30 17:03 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 2.95.3 4.3.0
Known to fail: 3.3.5 4.2.0 3.2.3 3.3.3 3.0.4 4.0.4 4.2.5
Last reconfirmed: 2007-08-06 14:43:50


Attachments
test case (517 bytes, application/octet-stream)
2006-08-16 17:29 UTC, David Woodhouse
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Woodhouse 2006-08-16 17:28:47 UTC
See attached test case. Observe the number of times certain lines of the 'vesa_modes' array are emitted. This isn't particularly optimal, especially as it happens even with -Os.

 $ make
cc -Os -c -o fbmon.o fbmon.i -save-temps
grep 39682 fbmon.s
        .long   39682
        .long   39682
Comment 1 David Woodhouse 2006-08-16 17:29:36 UTC
Created attachment 12084 [details]
test case
Comment 2 Andrew Pinski 2006-08-16 17:36:11 UTC
This is an expand/middle-end issue as get:
  *mode = vesa_modes[0];
in the final_cleanup.
Comment 3 Andrew Pinski 2006-08-16 17:37:29 UTC
Confirmed, here is the testcase for lazy people (like me) who really don't want to download the tar file:
struct fb_videomode {
 const char *name;
 unsigned refresh;
 unsigned xres;
 unsigned yres;
 unsigned pixclock;
 unsigned left_margin;
 unsigned right_margin;
 unsigned upper_margin;
 unsigned lower_margin;
 unsigned hsync_len;
 unsigned vsync_len;
 unsigned sync;
 unsigned vmode;
 unsigned flag;
};

const struct fb_videomode vesa_modes[] = {

 { ((void *)0), 60, 640, 480, 39682, 48, 16, 33, 10, 96, 2,
   0, 0, 4 },
};

void get_est_timing(unsigned char *block, struct fb_videomode *mode)
{
        mode[0] = vesa_modes[0];
}
-------
Oh this is not a regression as far as I can tell.
Comment 4 Andrew Pinski 2006-08-16 17:39:55 UTC
Actually it is a regression from 2.95.3, I just had to go back in time enough to get find that.
Comment 5 patchapp@dberlin.org 2006-08-21 04:29:41 UTC
Subject: Bug number PR middle-end/28755

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-08/msg00601.html
Comment 6 Gabriel Dos Reis 2007-02-03 18:56:34 UTC
Won't fix in GCC-4.0.x.  Adjusting milestone.
Comment 7 Jakub Jelinek 2007-09-23 09:34:48 UTC
Subject: Bug 28755

Author: jakub
Date: Sun Sep 23 09:34:28 2007
New Revision: 128685

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128685
Log:
	PR middle-end/28755
	* expr.c (expand_constructor): New function.
	(expand_expr_real_1) <case CONSTRUCTOR>: Call it.
	(expand_expr_real_1) <case ARRAY_REF>: Call it if VALUE is
	CONSTRUCTOR.

	* gcc.dg/pr28755.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr28755.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/expr.c
    trunk/gcc/testsuite/ChangeLog

Comment 8 Jakub Jelinek 2007-09-24 06:36:18 UTC
Fixed on the trunk.
Comment 9 Alexandre Pereira Nunes 2008-01-15 18:12:14 UTC
(In reply to comment #8)
> Fixed on the trunk.
> 

For anyone else wondering, this is still reproductible on vanilla gcc 4.2.2.
Comment 10 Joseph S. Myers 2008-07-04 21:27:55 UTC
Closing 4.1 branch.
Comment 11 Joseph S. Myers 2009-03-30 17:03:50 UTC
Closing 4.2 branch, fixed in 4.3.