From 771f882e18593bf51b526dc3cc75a41aaec2313c Mon Sep 17 00:00:00 2001 From: Zdenek Dvorak Date: Fri, 12 Dec 2008 21:32:47 +0100 Subject: re PR tree-optimization/32044 (final value replacement too aggressive for e.g. targets with no native div/mod insns) PR tree-optimization/32044 * tree-scalar-evolution.h (expression_expensive_p): Declare. * tree-scalar-evolution.c (expression_expensive_p): New function. (scev_const_prop): Avoid introducing expensive expressions. * tree-ssa-loop-ivopts.c (may_eliminate_iv): Ditto. * gcc.dg/pr34027-1.c: Change outcome. * gcc.dg/tree-ssa/pr32044.c: New test. From-SVN: r142719 --- gcc/testsuite/gcc.dg/pr34027-1.c | 6 +++- gcc/testsuite/gcc.dg/tree-ssa/pr32044.c | 55 +++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr32044.c (limited to 'gcc/testsuite/gcc.dg') diff --git a/gcc/testsuite/gcc.dg/pr34027-1.c b/gcc/testsuite/gcc.dg/pr34027-1.c index 532e497..8e8872a 100644 --- a/gcc/testsuite/gcc.dg/pr34027-1.c +++ b/gcc/testsuite/gcc.dg/pr34027-1.c @@ -8,5 +8,9 @@ unsigned long foobar(unsigned long ns) return ns; } -/* { dg-final { scan-tree-dump "ns % 10000" "optimized" } } */ +/* This test was originally introduced to test that we transform + to ns % 10000. See the discussion of PR 32044 why we do not do + that anymore. */ +/* { dg-final { scan-tree-dump-times "%" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "/" 0 "optimized" } } */ /* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr32044.c b/gcc/testsuite/gcc.dg/tree-ssa/pr32044.c new file mode 100644 index 0000000..0c1a582 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr32044.c @@ -0,0 +1,55 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-empty -fdump-tree-final_cleanup" } */ + +int foo (int n) +{ + while (n >= 45) + n -= 45; + + return n; +} + +int bar (int n) +{ + while (n >= 64) + n -= 64; + + return n; +} + +int bla (int n) +{ + int i = 0; + + while (n >= 45) + { + i++; + n -= 45; + } + + return i; +} + +int baz (int n) +{ + int i = 0; + + while (n >= 64) + { + i++; + n -= 64; + } + + return i; +} + +/* The loops computing division/modulo by 64 should be eliminated. */ +/* { dg-final { scan-tree-dump-times "Removing empty loop" 2 "empty" } } */ + +/* There should be no division/modulo in the final dump (division and modulo + by 64 are done using bit operations). */ +/* { dg-final { scan-tree-dump-times "/" 0 "final_cleanup" } } */ +/* { dg-final { scan-tree-dump-times "%" 0 "final_cleanup" } } */ + +/* { dg-final { cleanup-tree-dump "empty" } } */ +/* { dg-final { cleanup-tree-dump "final_cleanup" } } */ -- cgit v1.1