Commit a31d2741 by Thomas Preud'homme Committed by Thomas Preud'homme

re PR tree-optimization/61517 (wrong code at -Os and above on x86_64-linux-gnu)

2014-06-18  Thomas Preud'homme  <thomas.preudhomme@arm.com>

    gcc/
    PR tree-optimization/61517
    * tree-ssa-math-opts.c (find_bswap_or_nop_1): Adapt to return a stmt
    whose rhs's first tree is the source expression instead of the
    expression itself.
    (find_bswap_or_nop): Likewise.
    (bsap_replace): Rename stmt in cur_stmt. Pass gsi by value and src as a
    gimple stmt whose rhs's first tree is the source. In the memory source
    case, move the stmt to be replaced close to one of the original load to
    avoid the problem of a store between the load and the stmt's original
    location.
    (pass_optimize_bswap::execute): Adapt to change in bswap_replace's
    signature.

    gcc/testsuite/
    * gcc.c-torture/execute/bswap-2.c (incorrect_read_le32): New.
    (incorrect_read_be32): Likewise.
    (main): Call incorrect_read_* to test stmt replacement is made by
    bswap at the right place.
    * gcc.c-torture/execute/pr61517.c: New test.

From-SVN: r211778
parent a0f37b26
2014-06-18 Thomas Preud'homme <thomas.preudhomme@arm.com>
PR tree-optimization/61517
* tree-ssa-math-opts.c (find_bswap_or_nop_1): Adapt to return a stmt
whose rhs's first tree is the source expression instead of the
expression itself.
(find_bswap_or_nop): Likewise.
(bsap_replace): Rename stmt in cur_stmt. Pass gsi by value and src as a
gimple stmt whose rhs's first tree is the source. In the memory source
case, move the stmt to be replaced close to one of the original load to
avoid the problem of a store between the load and the stmt's original
location.
(pass_optimize_bswap::execute): Adapt to change in bswap_replace's
signature.
2014-06-18 Andreas Schwab <schwab@suse.de>
PR rtl-optimization/54555
......
2014-06-18 Thomas Preud'homme <thomas.preudhomme@arm.com>
PR tree-optimization/61517
* gcc.c-torture/execute/bswap-2.c (incorrect_read_le32): New.
(incorrect_read_be32): Likewise.
(main): Call incorrect_read_* to test stmt replacement is made by
bswap at the right place.
* gcc.c-torture/execute/pr61517.c: New test.
2014-06-18 Andreas Schwab <schwab@suse.de>
PR rtl-optimization/54555
......
......@@ -66,6 +66,32 @@ fake_read_be32 (char *x, char *y)
return c3 | c2 << 8 | c1 << 16 | c0 << 24;
}
__attribute__ ((noinline, noclone)) uint32_t
incorrect_read_le32 (char *x, char *y)
{
unsigned char c0, c1, c2, c3;
c0 = x[0];
c1 = x[1];
c2 = x[2];
c3 = x[3];
*y = 1;
return c0 | c1 << 8 | c2 << 16 | c3 << 24;
}
__attribute__ ((noinline, noclone)) uint32_t
incorrect_read_be32 (char *x, char *y)
{
unsigned char c0, c1, c2, c3;
c0 = x[0];
c1 = x[1];
c2 = x[2];
c3 = x[3];
*y = 1;
return c3 | c2 << 8 | c1 << 16 | c0 << 24;
}
int
main ()
{
......@@ -92,8 +118,17 @@ main ()
out = fake_read_le32 (cin, &cin[2]);
if (out != 0x89018583)
__builtin_abort ();
cin[2] = 0x87;
out = fake_read_be32 (cin, &cin[2]);
if (out != 0x83850189)
__builtin_abort ();
cin[2] = 0x87;
out = incorrect_read_le32 (cin, &cin[2]);
if (out != 0x89878583)
__builtin_abort ();
cin[2] = 0x87;
out = incorrect_read_be32 (cin, &cin[2]);
if (out != 0x83858789)
__builtin_abort ();
return 0;
}
int a, b, *c = &a;
unsigned short d;
int
main ()
{
unsigned int e = a;
*c = 1;
if (!b)
{
d = e;
*c = d | e;
}
if (a != 0)
__builtin_abort ();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment