From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1011) id 2413D3857023; Mon, 8 Aug 2022 20:44:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2413D3857023 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrew Macleod To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1995] Evaluate condition arguments with the correct type. X-Act-Checkin: gcc X-Git-Author: Andrew MacLeod X-Git-Refname: refs/heads/master X-Git-Oldrev: 053876cdbe8057210e6f4da4eec2df58f92ccd4c X-Git-Newrev: ef623bb58594958a7959f8f031f65a50eb0e5890 Message-Id: <20220808204418.2413D3857023@sourceware.org> Date: Mon, 8 Aug 2022 20:44:18 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Aug 2022 20:44:18 -0000 https://gcc.gnu.org/g:ef623bb58594958a7959f8f031f65a50eb0e5890 commit r13-1995-gef623bb58594958a7959f8f031f65a50eb0e5890 Author: Andrew MacLeod Date: Mon Aug 8 15:13:51 2022 -0400 Evaluate condition arguments with the correct type. Processing of a cond_expr requires that a range of the correct type for the operands of the cond_expr is passed in. PR tree-optimization/106556 gcc/ * gimple-range-gori.cc (gori_compute::condexpr_adjust): Use the type of the cond_expr operands being evaluted. gcc/testsuite/ * gfortran.dg/pr106556.f90: New. Diff: --- gcc/gimple-range-gori.cc | 11 ++++++----- gcc/testsuite/gfortran.dg/pr106556.f90 | 10 ++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index a43e44c841e..8879e44cba1 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -1398,16 +1398,17 @@ gori_compute::condexpr_adjust (vrange &r1, vrange &r2, gimple *, tree cond, } // Now solve for SSA1 or SSA2 if they are in the dependency chain. - Value_Range tmp (type); if (ssa1 && in_chain_p (ssa1, cond_name)) { - if (compute_operand_range (tmp, def_stmt, cond_true, ssa1, src)) - r1.intersect (tmp); + Value_Range tmp1 (TREE_TYPE (ssa1)); + if (compute_operand_range (tmp1, def_stmt, cond_true, ssa1, src)) + r1.intersect (tmp1); } if (ssa2 && in_chain_p (ssa2, cond_name)) { - if (compute_operand_range (tmp, def_stmt, cond_false, ssa2, src)) - r2.intersect (tmp); + Value_Range tmp2 (TREE_TYPE (ssa2)); + if (compute_operand_range (tmp2, def_stmt, cond_false, ssa2, src)) + r2.intersect (tmp2); } if (idx) { diff --git a/gcc/testsuite/gfortran.dg/pr106556.f90 b/gcc/testsuite/gfortran.dg/pr106556.f90 new file mode 100644 index 00000000000..01b89a8eee2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr106556.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! { dg-options "-O1 -fnon-call-exceptions -ftree-loop-if-convert" } + + +program p + real :: a(2) + + a(:) = 1.0 + if (minloc (a, dim = 1).ne.1) STOP 1 +end