diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2012-07-19 21:35:12 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2012-07-19 21:35:12 +0000 |
commit | 9402220cecec63a6e7d26ab0767a569f48a0385b (patch) | |
tree | 690fb10d1738f67c49fec46cc3c844fa7255f80b | |
parent | a3628196ec3dee889444cce725c810e84e36b670 (diff) | |
download | gcc-9402220cecec63a6e7d26ab0767a569f48a0385b.zip gcc-9402220cecec63a6e7d26ab0767a569f48a0385b.tar.gz gcc-9402220cecec63a6e7d26ab0767a569f48a0385b.tar.bz2 |
tree-ssa-forwprop.c (combine_conversions): Punt if the RHS of the defining statement is a SSA name that occurs in abnormal...
* tree-ssa-forwprop.c (combine_conversions): Punt if the RHS of the
defining statement is a SSA name that occurs in abnormal PHIs.
From-SVN: r189687
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt25.adb | 17 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt25_pkg1.adb | 10 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt25_pkg1.ads | 11 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt25_pkg2.adb | 8 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt25_pkg2.ads | 20 | ||||
-rw-r--r-- | gcc/tree-ssa-forwprop.c | 5 |
8 files changed, 82 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1a3d401..6d7f568 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2012-07-19 Eric Botcazou <ebotcazou@adacore.com> + * tree-ssa-forwprop.c (combine_conversions): Punt if the RHS of the + defining statement is a SSA name that occurs in abnormal PHIs. + +2012-07-19 Eric Botcazou <ebotcazou@adacore.com> + * gimple-fold.c (canonicalize_constructor_val): Strip only useless type conversions. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 740d26b..47ae24c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2012-07-19 Eric Botcazou <ebotcazou@adacore.com> + * gnat.dg/opt25.adb: New test. + * gnat.dg/opt25_pkg1.ad[sb]: New helper. + * gnat.dg/opt25_pkg2.ad[sb]: Likewise + +2012-07-19 Eric Botcazou <ebotcazou@adacore.com> + * gnat.dg/aggr20.ad[sb]: New test. * gnat.dg/aggr20_pkg.ads: New helper. diff --git a/gcc/testsuite/gnat.dg/opt25.adb b/gcc/testsuite/gnat.dg/opt25.adb new file mode 100644 index 0000000..5046d16 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt25.adb @@ -0,0 +1,17 @@ +-- { dg-do compile } +-- { dg-options "-O" } + +with Opt25_Pkg1; +with Opt25_Pkg2; + +procedure Opt25 (B1, B2 : in out Boolean) is + + package Local_Pack_Instance is new Opt25_Pkg1 (Boolean, True); + + package Local_Stack is new Opt25_Pkg2 (Integer, 0); + + S : Local_Stack.Stack := Local_Stack.Default_Stack; + +begin + Local_Pack_Instance.Swap (B1, B2); +end; diff --git a/gcc/testsuite/gnat.dg/opt25_pkg1.adb b/gcc/testsuite/gnat.dg/opt25_pkg1.adb new file mode 100644 index 0000000..c18694f --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt25_pkg1.adb @@ -0,0 +1,10 @@ +package body Opt25_Pkg1 is + + procedure Swap (A, B : in out T) is + Tmp : T := A; + begin + A := B; + B := Tmp; + end Swap; + +end Opt25_Pkg1; diff --git a/gcc/testsuite/gnat.dg/opt25_pkg1.ads b/gcc/testsuite/gnat.dg/opt25_pkg1.ads new file mode 100644 index 0000000..7a96f27 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt25_pkg1.ads @@ -0,0 +1,11 @@ +generic + + type T is private; + Init_Value : T; + +package Opt25_Pkg1 is + + Var : T := Init_Value; + procedure Swap (A, B : in out T); + +end Opt25_Pkg1; diff --git a/gcc/testsuite/gnat.dg/opt25_pkg2.adb b/gcc/testsuite/gnat.dg/opt25_pkg2.adb new file mode 100644 index 0000000..164ef33 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt25_pkg2.adb @@ -0,0 +1,8 @@ +package body Opt25_Pkg2 is + + function Default_Stack return Stack is + begin + return Default_Stack_Var; + end Default_Stack; + +end Opt25_Pkg2; diff --git a/gcc/testsuite/gnat.dg/opt25_pkg2.ads b/gcc/testsuite/gnat.dg/opt25_pkg2.ads new file mode 100644 index 0000000..f127308 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt25_pkg2.ads @@ -0,0 +1,20 @@ +generic + + type Value is private; + Init_Val : Value; + +package Opt25_Pkg2 is + + type Stack (Size : Natural) is private; + + function Default_Stack return Stack; + +private + type Value_Array is array (Natural range <>) of Value; + + type Stack (Size : Natural) is record + Store : Value_Array (1 .. Size); + end record; + + Default_Stack_Var : Stack (10); +end Opt25_Pkg2; diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 2ab4b23..c265f71 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -2584,6 +2584,11 @@ combine_conversions (gimple_stmt_iterator *gsi) unsigned int final_prec = TYPE_PRECISION (type); int final_unsignedp = TYPE_UNSIGNED (type); + /* Don't propagate ssa names that occur in abnormal phis. */ + if (TREE_CODE (defop0) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (defop0)) + return 0; + /* In addition to the cases of two conversions in a row handled below, if we are converting something to its own type via an object of identical or wider precision, neither |