summaryrefslogtreecommitdiff
path: root/gcc/fortran/frontend-passes.c
diff options
context:
space:
mode:
authortkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>2013-04-30 21:45:13 +0000
committertkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>2013-04-30 21:45:13 +0000
commit3c73c0fb0a2396d2257b8d6192fc70102c52d458 (patch)
treeefd1bbd12f3f9ffed58a0089a798e89c2ca28db9 /gcc/fortran/frontend-passes.c
parent2f96cc7d47b14873d577551358d49d602ddf393c (diff)
downloadgcc-3c73c0fb0a2396d2257b8d6192fc70102c52d458.tar.gz
2013-04-30 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/57071 * frontend-passes.c (optimize_power): Simplify 1**k to 1. 2013-04-30 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/57071 * gfortran.dg/power_5.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198476 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/frontend-passes.c')
-rw-r--r--gcc/fortran/frontend-passes.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index 63efb9f919c..a2e88b4f408 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -1148,6 +1148,24 @@ optimize_power (gfc_expr *e)
*e = *ishft;
return true;
}
+
+ else if (mpz_cmp_si (op1->value.integer, 1L) == 0)
+ {
+ op2 = e->value.op.op2;
+ if (op2 == NULL)
+ return false;
+
+ gfc_free_expr (op1);
+ gfc_free_expr (op2);
+
+ e->expr_type = EXPR_CONSTANT;
+ e->value.op.op1 = NULL;
+ e->value.op.op2 = NULL;
+ mpz_init_set_si (e->value.integer, 1);
+ /* Typespec cand location are still OK. */
+ return true;
+ }
+
return false;
}