diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ef18defe74844456bc529e24323b44d2c12a01a9..be1cbe574446955f6e458a3eaf2f7eded1f0a678 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2019-03-01  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/89541
+	* tree-ssa-operands.c (add_stmt_operand): CONST_DECL may
+	get virtual operands.
+	(get_expr_operands): Handle CONST_DECL like other decls.
+
 2019-03-01  Jakub Jelinek  <jakub@redhat.com>
 
 	PR middle-end/89503
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b1b4886c3ef11cd0823a85556c0b5dd1575192a9..f6a8e6a44383955df2a5da71a69e48302bbb03c7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-03-01  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/89541
+	* gfortran.dg/pr89451.f90: New testcase.
+
 2019-03-01  Richard Biener  <rguenther@suse.de>
 
 	PR middle-end/89497
diff --git a/gcc/testsuite/gfortran.dg/pr89451.f90 b/gcc/testsuite/gfortran.dg/pr89451.f90
new file mode 100644
index 0000000000000000000000000000000000000000..e751488d2248f444781c4f09e3cf3add1cc171af
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr89451.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! { dg-options "-O2" }
+program lh
+  call za(0)
+  call za(0)
+contains
+  subroutine za(wl)
+    integer wl
+    wl = 1
+  end subroutine za
+end program lh
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index fb247324cecaab5e1a5ad0a3ad418ee60d499642..899d47ff588d504697321cf699c1a2cb7cf965bb 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -515,7 +515,9 @@ add_stmt_operand (struct function *fn, tree *var_p, gimple *stmt, int flags)
 {
   tree var = *var_p;
 
-  gcc_assert (SSA_VAR_P (*var_p) || TREE_CODE (*var_p) == STRING_CST);
+  gcc_assert (SSA_VAR_P (*var_p)
+	      || TREE_CODE (*var_p) == STRING_CST
+	      || TREE_CODE (*var_p) == CONST_DECL);
 
   if (is_gimple_reg (var))
     {
@@ -741,6 +743,7 @@ get_expr_operands (struct function *fn, gimple *stmt, tree *expr_p, int flags)
     case PARM_DECL:
     case RESULT_DECL:
     case STRING_CST:
+    case CONST_DECL:
       if (!(flags & opf_address_taken))
 	add_stmt_operand (fn, expr_p, stmt, flags);
       return;
@@ -859,7 +862,6 @@ get_expr_operands (struct function *fn, gimple *stmt, tree *expr_p, int flags)
 
     case FUNCTION_DECL:
     case LABEL_DECL:
-    case CONST_DECL:
     case CASE_LABEL_EXPR:
       /* Expressions that make no memory references.  */
       return;