public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-3508] Check if varying may also be non-negative.
@ 2022-10-26 13:49 Andrew Macleod
0 siblings, 0 replies; only message in thread
From: Andrew Macleod @ 2022-10-26 13:49 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a87819b8f1b890d36a3f05bd9de80be20e9525dd
commit r13-3508-ga87819b8f1b890d36a3f05bd9de80be20e9525dd
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Tue Oct 25 15:16:47 2022 -0400
Check if varying may also be non-negative.
When using strict enums, we can sometimes turn varying into a better
range.
* gimple-range-fold.cc (fold_using_range::fold_stmt): Check if
stmt is non-negative and adjust the range.
Diff:
---
gcc/gimple-range-fold.cc | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index f91923782dc..a899d8260b3 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -494,6 +494,14 @@ fold_using_range::fold_stmt (vrange &r, gimple *s, fur_source &src, tree name)
else if (is_a<gassign *> (s) && gimple_assign_rhs_code (s) == COND_EXPR)
res = range_of_cond_expr (r, as_a<gassign *> (s), src);
+ // If the result is varying, check for basic nonnegativeness.
+ // Specifically this helps for now with strict enum in cases like
+ // g++.dg/warn/pr33738.C.
+ bool so_p;
+ if (res && r.varying_p () && INTEGRAL_TYPE_P (r.type ())
+ && gimple_stmt_nonnegative_warnv_p (s, &so_p))
+ r.set_nonnegative (r.type ());
+
if (!res)
{
// If no name specified or range is unsupported, bail.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-26 13:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26 13:49 [gcc r13-3508] Check if varying may also be non-negative Andrew Macleod
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).