Bug 39734 - Misordering of instructions for short moves in a C program
Summary: Misordering of instructions for short moves in a C program
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.1.2
: P3 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-11 06:45 UTC by Vasanthy Kolluri
Modified: 2009-04-25 11:08 UTC (History)
30 users (show)

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


Attachments
gcc version,system type etc (876 bytes, text/plain)
2009-04-11 06:48 UTC, Vasanthy Kolluri
Details
preprocessed file (6.92 KB, application/octet-stream)
2009-04-11 06:49 UTC, Vasanthy Kolluri
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vasanthy Kolluri 2009-04-11 06:45:32 UTC
 
Comment 1 Vasanthy Kolluri 2009-04-11 06:48:04 UTC
Created attachment 17616 [details]
gcc version,system type etc
Comment 2 Vasanthy Kolluri 2009-04-11 06:49:34 UTC
Created attachment 17617 [details]
preprocessed file
Comment 3 Vasanthy Kolluri 2009-04-11 06:58:41 UTC
The short moves(16-bit)do not work when the -O3 optimization flag is set. It turns out that there are a couple of instances of instruction misordering in the asm code.

The same program works fine without the optimization flags set.Also, it works for gcc version #3.
Comment 4 Andrew Pinski 2009-04-11 07:20:19 UTC
    u_int32_t mask[1] = { 0xffffffff };
    u_int32_t cfg[1] = { 0x11111111 };

    u_int16_t *cfg16 = (u_int16_t *)cfg;
    u_int16_t *mask16 = (u_int16_t *)mask;

    printf("mask16[0]: 0x%04x\n", mask16[0]);

You are violating C/C++ aliasing rules as you are accessing a u_int32_t as a u_int16_t.

*** This bug has been marked as a duplicate of 21920 ***