Commit 30da41ed by Xinliang David Li Committed by Xinliang David Li

Check in tree-dce enh to trunk

From-SVN: r135463
parent b61eacd6
2008-05-17 Xinliang David Li <davidxl@google.com>
* gcc/tree-ssa-dce.c : conditional dead call elimination
* gcc/opts.c : enable the optimization at >=O2
* gcc/common.opt : new flag for control the optimization
* gcc/doc/invoke.texi : documentation change
* gcc/testsuite/gcc.dg/cdce1.c : new test case
* gcc/testsuite/gcc.dg/cdce2.c : new test case
*MAINTAINERS : Add myself (write after approval)
2008-05-15 Janus Weil <janus@gcc.gnu.org> 2008-05-15 Janus Weil <janus@gcc.gnu.org>
* MAINTAINERS (Write After Approval): Add myself. * MAINTAINERS (Write After Approval): Add myself.
......
...@@ -372,6 +372,7 @@ Manuel Lpez-Ibez manu@gcc.gnu.org ...@@ -372,6 +372,7 @@ Manuel Lpez-Ibez manu@gcc.gnu.org
Dave Love d.love@dl.ac.uk Dave Love d.love@dl.ac.uk
Martin v. Lwis loewis@informatik.hu-berlin.de Martin v. Lwis loewis@informatik.hu-berlin.de
H.J. Lu hjl.tools@gmail.com H.J. Lu hjl.tools@gmail.com
Xinliang David Li davidxl@google.com
William Maddox maddox@google.com William Maddox maddox@google.com
Ziga Mahkovec ziga.mahkovec@klika.si Ziga Mahkovec ziga.mahkovec@klika.si
Simon Martin simartin@users.sourceforge.net Simon Martin simartin@users.sourceforge.net
......
...@@ -1259,6 +1259,10 @@ fweb ...@@ -1259,6 +1259,10 @@ fweb
Common Report Var(flag_web) Init(2) Optimization Common Report Var(flag_web) Init(2) Optimization
Construct webs and split unrelated uses of single variable Construct webs and split unrelated uses of single variable
ftree-builtin-dce
Common Report Var(flag_tree_builtin_dce) Init(0) Optimization
Enable conditional dead code elimination for builtin calls.
fwhole-program fwhole-program
Common Report Var(flag_whole_program) Init(0) Optimization Common Report Var(flag_whole_program) Init(0) Optimization
Perform whole program optimizations Perform whole program optimizations
......
...@@ -353,7 +353,7 @@ Objective-C and Objective-C++ Dialects}. ...@@ -353,7 +353,7 @@ Objective-C and Objective-C++ Dialects}.
-fsignaling-nans -fsingle-precision-constant -fsplit-ivs-in-unroller @gol -fsignaling-nans -fsingle-precision-constant -fsplit-ivs-in-unroller @gol
-fsplit-wide-types -fstack-protector -fstack-protector-all @gol -fsplit-wide-types -fstack-protector -fstack-protector-all @gol
-fstrict-aliasing -fstrict-overflow -fthread-jumps -ftracer -ftree-ccp @gol -fstrict-aliasing -fstrict-overflow -fthread-jumps -ftracer -ftree-ccp @gol
-ftree-ch -ftree-copy-prop -ftree-copyrename -ftree-dce @gol -ftree-ch -ftree-copy-prop -ftree-copyrename -ftree-dce -ftree-builtin-dce@gol
-ftree-dominator-opts -ftree-dse -ftree-fre -ftree-loop-im @gol -ftree-dominator-opts -ftree-dse -ftree-fre -ftree-loop-im @gol
-ftree-loop-distribution @gol -ftree-loop-distribution @gol
-ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize @gol -ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize @gol
...@@ -5157,6 +5157,7 @@ compilation time. ...@@ -5157,6 +5157,7 @@ compilation time.
-ftree-ch @gol -ftree-ch @gol
-ftree-copyrename @gol -ftree-copyrename @gol
-ftree-dce @gol -ftree-dce @gol
-ftree-builtin-dce @gol
-ftree-dominator-opts @gol -ftree-dominator-opts @gol
-ftree-dse @gol -ftree-dse @gol
-ftree-fre @gol -ftree-fre @gol
...@@ -5873,6 +5874,12 @@ enabled by default at @option{-O2} and higher. ...@@ -5873,6 +5874,12 @@ enabled by default at @option{-O2} and higher.
Perform dead code elimination (DCE) on trees. This flag is enabled by Perform dead code elimination (DCE) on trees. This flag is enabled by
default at @option{-O} and higher. default at @option{-O} and higher.
@item -ftree-builtin-dce
@opindex ftree-builtin-dce
Perform conditional dead code elimination (DCE) on builtin calls that
may set errno but are otherwise side-effect free. This flag is enabled by
default at @option{-O} and higher.
@item -ftree-dominator-opts @item -ftree-dominator-opts
@opindex ftree-dominator-opts @opindex ftree-dominator-opts
Perform a variety of simple scalar cleanups (constant/copy Perform a variety of simple scalar cleanups (constant/copy
......
...@@ -886,6 +886,7 @@ decode_options (unsigned int argc, const char **argv) ...@@ -886,6 +886,7 @@ decode_options (unsigned int argc, const char **argv)
flag_reorder_functions = 1; flag_reorder_functions = 1;
flag_tree_store_ccp = 1; flag_tree_store_ccp = 1;
flag_tree_vrp = 1; flag_tree_vrp = 1;
flag_tree_builtin_dce = 1;
if (!optimize_size) if (!optimize_size)
{ {
......
/* { dg-do run } */
/* { dg-options "-O2 -fdump-tree-dce1-details -lm" } */
/* { dg-message "note: function call is shrink-wrapped into error conditions\." "Missing conditional dce" {target "*-*-*"} 15 } */
#include <stdlib.h>
#include <math.h>
#include <errno.h>
#include <stdio.h>
int total_err_count = 0;
double foo_opt(int x, double y) __attribute__((noinline));
double foo_opt(int x, double y)
{
double yy = 0;
errno = 0;
yy = pow(x,y);
return 0;
}
double foo(int x, double y) __attribute__((noinline));
double foo(int x, double y)
{
double yy = 0;
errno = 0;
yy = pow(x,y);
return yy;
}
int test(double (*fp)(int x, double y))
{
int i,x;
x = 127;
for (i = 30; i < 300; i++)
{
fp(x,i);
if (errno)
total_err_count ++;
}
x = -300;
for (i = 100; i < 300; i++)
{
fp(x,i);
if (errno)
total_err_count ++;
}
x = 65577;
for (i = 60; i < 200; i++)
{
fp(x,i);
if (errno)
total_err_count ++;
}
x = 65577*127;
for (i = 1; i < 100; i++)
{
fp(x,i);
if (errno)
total_err_count ++;
}
return total_err_count;
}
int main()
{
int en1, en2;
total_err_count = 0;
en1 = test(foo_opt);
total_err_count = 0;
en2 = test(foo);
printf("total number of errors = %d, %d\n", en1, en2);
if (en1 != en2)
abort();
return 0;
}
/* { dg-do run } */
/* { dg-options "-O2 -fdump-tree-dce1-details -lm" } */
/* { dg-message "note: function call is shrink-wrapped into error conditions\." "Missing conditional dce" {target "*-*-*"} 15 } */
#include <stdlib.h>
#include <math.h>
#include <errno.h>
#include <stdio.h>
int total_err_count = 0;
double foo_opt(double y) __attribute__((noinline));
double foo_opt(double y)
{
double yy = 0;
errno = 0;
yy = log(y);
return 0;
}
double foo(double y) __attribute__((noinline));
double foo(double y)
{
double yy = 0;
errno = 0;
yy = log(y);
return yy;
}
int test(double (*fp)(double y) )
{
int i,x;
for (i = -100; i < 100; i++)
{
fp(i);
if (errno)
total_err_count ++;
}
return total_err_count;
}
int main()
{
int en1, en2;
double yy;
total_err_count = 0;
en1 = test(foo_opt);
total_err_count = 0;
en2 = test(foo);
if (en1 != en2)
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