From: Andrew MacLeod <amacleod@redhat.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [COMMITTED] PR tree-optimization/106556 - Evaluate condition arguments with the correct type.
Date: Mon, 8 Aug 2022 16:44:35 -0400 [thread overview]
Message-ID: <8b1c215e-263e-b24d-9ab7-5b40c62142d5@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 403 bytes --]
when evaluating a COND_EXPR, we need to evaluate both operands. With the
recent changes to floating point, we missed that we are accidentally
using the LHS range type for the operands.. that was fine when
everything was an irange... but no so any more.
This patch simply uses the right range type for the temporary ranges.
Bootstrapped on x86_64-pc-linux-gnu with no regressions. Pushed.
Andrew
[-- Attachment #2: 556.diff --]
[-- Type: text/x-patch, Size: 1977 bytes --]
commit 6d57764711d3b4441d4d99876d9d3370bdec6284
Author: Andrew MacLeod <amacleod@redhat.com>
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 --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
reply other threads:[~2022-08-08 20:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8b1c215e-263e-b24d-9ab7-5b40c62142d5@redhat.com \
--to=amacleod@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).