mirror of git://gcc.gnu.org/git/gcc.git
re PR tree-optimization/58775 (reassoc1 causes an ICE with some bool arithmetic)
PR tree-optimization/58775 PR tree-optimization/58791 * tree-ssa-reassoc.c (reassoc_stmt_dominates_stmt_p): New function. (insert_stmt_after): Rewritten, don't move the stmt, but really insert it. (get_stmt_uid_with_default): Remove. (build_and_add_sum): Use insert_stmt_after and reassoc_stmt_dominates_stmt_p. Fix up uid if bb contains only labels. (update_range_test): Set uid on stmts added by force_gimple_operand_gsi. Don't immediately modify statements in inter-bb optimization, just update oe->op values. (optimize_range_tests): Return bool whether any changed have been made. (update_ops): New function. (struct inter_bb_range_test_entry): New type. (maybe_optimize_range_tests): Perform statement changes here. (not_dominated_by, appears_later_in_bb, get_def_stmt, ensure_ops_are_available): Remove. (find_insert_point): Rewritten. (rewrite_expr_tree): Remove MOVED argument, add CHANGED argument, return LHS of the (new resp. old) stmt. Don't call ensure_ops_are_available, don't reuse SSA_NAMEs, recurse first instead of last, move new stmt at the right place. (linearize_expr, repropagate_negates): Don't reuse SSA_NAMEs. (negate_value): Likewise. Set uids. (break_up_subtract_bb): Initialize uids. (reassociate_bb): Adjust rewrite_expr_tree caller. (do_reassoc): Don't call renumber_gimple_stmt_uids. * gcc.dg/guality/pr58791-1.c: New test. * gcc.dg/guality/pr58791-2.c: New test. * gcc.dg/guality/pr58791-3.c: New test. * gcc.dg/guality/pr58791-4.c: New test. * gcc.dg/guality/pr58791-5.c: New test. * gcc.c-torture/compile/pr58775.c: New test. * gcc.dg/tree-ssa/reassoc-28.c: Don't scan reassoc1 dump. From-SVN: r203979
This commit is contained in:
parent
66caf47a50
commit
5e40da4f64
|
|
@ -1,3 +1,35 @@
|
|||
2013-10-23 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR tree-optimization/58775
|
||||
PR tree-optimization/58791
|
||||
* tree-ssa-reassoc.c (reassoc_stmt_dominates_stmt_p): New function.
|
||||
(insert_stmt_after): Rewritten, don't move the stmt, but really
|
||||
insert it.
|
||||
(get_stmt_uid_with_default): Remove.
|
||||
(build_and_add_sum): Use insert_stmt_after and
|
||||
reassoc_stmt_dominates_stmt_p. Fix up uid if bb contains only
|
||||
labels.
|
||||
(update_range_test): Set uid on stmts added by
|
||||
force_gimple_operand_gsi. Don't immediately modify statements
|
||||
in inter-bb optimization, just update oe->op values.
|
||||
(optimize_range_tests): Return bool whether any changed have
|
||||
been made.
|
||||
(update_ops): New function.
|
||||
(struct inter_bb_range_test_entry): New type.
|
||||
(maybe_optimize_range_tests): Perform statement changes here.
|
||||
(not_dominated_by, appears_later_in_bb, get_def_stmt,
|
||||
ensure_ops_are_available): Remove.
|
||||
(find_insert_point): Rewritten.
|
||||
(rewrite_expr_tree): Remove MOVED argument, add CHANGED argument,
|
||||
return LHS of the (new resp. old) stmt. Don't call
|
||||
ensure_ops_are_available, don't reuse SSA_NAMEs, recurse first
|
||||
instead of last, move new stmt at the right place.
|
||||
(linearize_expr, repropagate_negates): Don't reuse SSA_NAMEs.
|
||||
(negate_value): Likewise. Set uids.
|
||||
(break_up_subtract_bb): Initialize uids.
|
||||
(reassociate_bb): Adjust rewrite_expr_tree caller.
|
||||
(do_reassoc): Don't call renumber_gimple_stmt_uids.
|
||||
|
||||
2013-10-23 David Edelsohn <dje.gcc@gmail.com>
|
||||
|
||||
PR target/58838
|
||||
|
|
|
|||
|
|
@ -1,3 +1,15 @@
|
|||
2013-10-23 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR tree-optimization/58775
|
||||
PR tree-optimization/58791
|
||||
* gcc.dg/guality/pr58791-1.c: New test.
|
||||
* gcc.dg/guality/pr58791-2.c: New test.
|
||||
* gcc.dg/guality/pr58791-3.c: New test.
|
||||
* gcc.dg/guality/pr58791-4.c: New test.
|
||||
* gcc.dg/guality/pr58791-5.c: New test.
|
||||
* gcc.c-torture/compile/pr58775.c: New test.
|
||||
* gcc.dg/tree-ssa/reassoc-28.c: Don't scan reassoc1 dump.
|
||||
|
||||
2013-10-23 Tom de Vries <tom@codesourcery.com>
|
||||
|
||||
PR tree-optimization/58805
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
/* PR tree-optimization/58775 */
|
||||
|
||||
void bar (void);
|
||||
|
||||
void
|
||||
foo (char *x)
|
||||
{
|
||||
char a;
|
||||
_Bool b, c, d, e, f, g, h, i, j, k, l, m;
|
||||
|
||||
a = *x;
|
||||
b = a == 100;
|
||||
c = a == 105;
|
||||
d = b | c;
|
||||
e = a != 111;
|
||||
f = !d;
|
||||
g = e & f;
|
||||
h = a != 117;
|
||||
i = g & h;
|
||||
j = a != 120;
|
||||
k = i & j;
|
||||
l = a != 88;
|
||||
m = k & l;
|
||||
if (m == 0)
|
||||
bar ();
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/* PR tree-optimization/58791 */
|
||||
/* { dg-do run } */
|
||||
/* { dg-options "-g" } */
|
||||
|
||||
#include "../nop.h"
|
||||
|
||||
__attribute__((noinline, noclone)) int
|
||||
foo (int x, int y)
|
||||
{
|
||||
_Bool a = x != 0;
|
||||
_Bool b = y != 2;
|
||||
_Bool c = a & b;
|
||||
_Bool d = !c;
|
||||
int ret;
|
||||
if (c)
|
||||
{
|
||||
if (y < 3 || y > 4)
|
||||
ret = 1;
|
||||
else
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
ret = 0;
|
||||
asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr58791-1.c:25 "c & 1" "1" } } */
|
||||
asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr58791-1.c:25 "d & 1" "0" } } */
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
foo (1, 3);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/* PR tree-optimization/58791 */
|
||||
/* { dg-do run } */
|
||||
/* { dg-options "-g" } */
|
||||
|
||||
#include "../nop.h"
|
||||
|
||||
__attribute__((noinline, noclone)) int
|
||||
foo (unsigned char c)
|
||||
{
|
||||
int ret;
|
||||
_Bool a, b, d, e, f;
|
||||
|
||||
a = c == 34;
|
||||
b = c == 32;
|
||||
d = a | b;
|
||||
f = !d;
|
||||
if (d)
|
||||
ret = 1;
|
||||
else
|
||||
{
|
||||
e = c <= 31;
|
||||
ret = e;
|
||||
}
|
||||
|
||||
asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr58791-2.c:27 "d & 1" "1" } } */
|
||||
asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr58791-2.c:27 "f & 1" "0" } } */
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
foo (32);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
/* PR tree-optimization/58791 */
|
||||
/* { dg-do run } */
|
||||
/* { dg-options "-g" } */
|
||||
|
||||
#include "../nop.h"
|
||||
|
||||
__attribute__((noinline, noclone)) unsigned
|
||||
foo (unsigned a, unsigned b, unsigned c, unsigned d, unsigned e)
|
||||
{
|
||||
unsigned f = b + c; /* { dg-final { gdb-test pr58791-3.c:19 "f" "5" } } */
|
||||
unsigned g = a - f; /* { dg-final { gdb-test pr58791-3.c:19 "g" "24" } } */
|
||||
unsigned h = d + e; /* { dg-final { gdb-test pr58791-3.c:19 "h" "9" } } */
|
||||
unsigned i = g - h; /* { dg-final { gdb-test pr58791-3.c:19 "i" "15" } } */
|
||||
unsigned j = f + 1; /* { dg-final { gdb-test pr58791-3.c:19 "j" "6" } } */
|
||||
unsigned k = g + 1; /* { dg-final { gdb-test pr58791-3.c:19 "k" "25" } } */
|
||||
unsigned l = h + 1; /* { dg-final { gdb-test pr58791-3.c:19 "l" "10" } } */
|
||||
unsigned m = i + 1; /* { dg-final { gdb-test pr58791-3.c:19 "m" "16" } } */
|
||||
asm volatile (NOP : : : "memory");
|
||||
asm volatile (NOP : : : "memory");
|
||||
return i;
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
foo (29, 2, 3, 4, 5);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/* PR tree-optimization/58791 */
|
||||
/* { dg-do run } */
|
||||
/* { dg-options "-g -ffast-math" } */
|
||||
|
||||
#include "../nop.h"
|
||||
|
||||
__attribute__((noinline, noclone)) double
|
||||
foo (float a, float b, float c, float d, float l, double u)
|
||||
{
|
||||
float e = a * d;
|
||||
float f = d * e;
|
||||
double g = (double) f;
|
||||
double h = (double) b;
|
||||
double i = g * h; /* { dg-final { gdb-test pr58791-4.c:32 "i" "486" { target { x86_64-*-* && lp64 } } } } */
|
||||
double i2 = i + 1.0; /* { dg-final { gdb-test pr58791-4.c:32 "i2" "487" { target { x86_64-*-* && lp64 } } } } */
|
||||
double j = i * 3.25;
|
||||
double k = h + j;
|
||||
float m = l * 8.75;
|
||||
double n = (double) m;
|
||||
double o = (double) a;
|
||||
double p = n * o;
|
||||
double q = h * p;
|
||||
double r = q * 2.5;
|
||||
double s = k - r;
|
||||
double t = (double) c;
|
||||
double v = o * u;
|
||||
double w = o * v;
|
||||
double x = h * w;
|
||||
double y = h * x;
|
||||
double z = y * 8.5;
|
||||
asm volatile (NOP : : : "memory");
|
||||
asm volatile (NOP : : : "memory");
|
||||
return s - z;
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
foo (3.0f, 2.0f, -1.0f, 9.0f, 1.0f, 2.0);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
/* PR tree-optimization/58791 */
|
||||
/* { dg-do run } */
|
||||
/* { dg-options "-g" } */
|
||||
|
||||
#include "../nop.h"
|
||||
|
||||
__attribute__((noinline, noclone)) unsigned int
|
||||
foo (unsigned int a0, unsigned int a1, unsigned int a2,
|
||||
unsigned int a3, unsigned int a4)
|
||||
{
|
||||
unsigned int b0, b1, b2, b3, b4, e;
|
||||
/* this can be optimized to four additions... */
|
||||
b4 = a4 + a3 + a2 + a1 + a0; /* { dg-final { gdb-test pr58791-5.c:20 "b4" "4681" } } */
|
||||
b3 = a3 + a2 + a1 + a0; /* { dg-final { gdb-test pr58791-5.c:20 "b3" "585" } } */
|
||||
b2 = a2 + a1 + a0; /* { dg-final { gdb-test pr58791-5.c:20 "b2" "73" } } */
|
||||
b1 = a1 + a0; /* { dg-final { gdb-test pr58791-5.c:20 "b1" "9" } } */
|
||||
/* This is actually 0 */
|
||||
e = b4 - b3 + b2 - b1 - a4 - a2; /* { dg-final { gdb-test pr58791-5.c:20 "e" "0" } } */
|
||||
asm volatile (NOP : : : "memory");
|
||||
asm volatile (NOP : : : "memory");
|
||||
return e;
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
foo (1, 8, 64, 512, 4096);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/* { dg-do run} */
|
||||
/* { dg-options "-O2 -fdump-tree-reassoc1-details" } */
|
||||
/* { dg-options "-O2" } */
|
||||
|
||||
#define LENGTH 4
|
||||
void abort (void);
|
||||
|
|
@ -30,8 +30,3 @@ int main() {
|
|||
abort ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Verify one stmt has been moved to another BB to ensure correct dependences. */
|
||||
/* { dg-final { scan-tree-dump-times "to a different BB" 1 "reassoc1"} }*/
|
||||
/* { dg-final { scan-tree-dump-times "within same BB" 2 "reassoc1"} }*/
|
||||
/* { dg-final { cleanup-tree-dump "reassoc1" } } */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue