aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/frontend-passes.c
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2010-08-02 16:53:51 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2010-08-02 16:53:51 +0000
commit071bdb5f22d6f180a0acf906e2e1e392c47a0394 (patch)
tree479f0423955a284d5abd1abccc5b3bab38efbc1e /gcc/fortran/frontend-passes.c
parent20769d5eb6854f1dec44744721ec17c52609254d (diff)
downloadgcc-071bdb5f22d6f180a0acf906e2e1e392c47a0394.zip
gcc-071bdb5f22d6f180a0acf906e2e1e392c47a0394.tar.gz
gcc-071bdb5f22d6f180a0acf906e2e1e392c47a0394.tar.bz2
re PR fortran/36854 ([meta-bug] fortran front-end optimization)
2010-08-02 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/36854 * dependency.h: Add prototype for gfc_are_identical_variables. * frontend-passes.c: Include depencency.h. (optimimize_equality): Use gfc_are_identical_variables. * dependency.c (identical_array_ref): New function. (gfc_are_identical_variables): New function. (gfc_deb_compare_expr): Use gfc_are_identical_variables. * dependency.c (gfc_check_section_vs_section). Rename gfc_ prefix from statc function. (check_section_vs_section): Change arguments to gfc_array_ref, adjust function body accordingly. 2010-08-02 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/36854 * gfortran.dg/character_comparison_2.f90: New test. * gfortran.dg/character_comparison_3.f90: New test. * gfortran.dg/dependency_28.f90: New test. From-SVN: r162824
Diffstat (limited to 'gcc/fortran/frontend-passes.c')
-rw-r--r--gcc/fortran/frontend-passes.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index 83251cc..ce3ee9a 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see
#include "gfortran.h"
#include "arith.h"
#include "flags.h"
+#include "dependency.h"
/* Forward declarations. */
@@ -398,14 +399,13 @@ optimize_equality (gfc_expr *e, bool equal)
return true;
}
- /* Check for direct comparison between identical variables.
- TODO: Handle cases with identical refs. */
+ /* Check for direct comparison between identical variables. Don't compare
+ REAL or COMPLEX because of NaN checks. */
if (op1->expr_type == EXPR_VARIABLE
&& op2->expr_type == EXPR_VARIABLE
- && op1->symtree == op2->symtree
- && op1->ref == NULL && op2->ref == NULL
&& op1->ts.type != BT_REAL && op2->ts.type != BT_REAL
- && op1->ts.type != BT_COMPLEX && op2->ts.type !=BT_COMPLEX)
+ && op1->ts.type != BT_COMPLEX && op2->ts.type !=BT_COMPLEX
+ && gfc_are_identical_variables (op1, op2))
{
/* Replace the expression by a constant expression. The typespec
and where remains the way it is. */