public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-755] Skip out on processing __builtin_clz when varying.
@ 2021-05-12 21:03 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2021-05-12 21:03 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d902a1b57606536982a1001670f998de685eaf7c

commit r12-755-gd902a1b57606536982a1001670f998de685eaf7c
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Wed May 12 15:22:15 2021 -0400

    Skip out on processing __builtin_clz when varying.
    
    The previous changes to irange::constant_p return TRUE for
    VARYING, since VARYING has numerical end points like any other
    constant range.  The problem is that some users of constant_p
    depended on constant_p excluding the full domain.  The
    range handler for __builtin_clz, that is shared between ranger
    and vr_values, is one such user.
    
    This patch excludes varying_p(), to match the original behavior
    for clz.
    
    gcc/ChangeLog:
    
            PR c/100521
            * gimple-range.cc (range_of_builtin_call): Skip out on
              processing __builtin_clz when varying.

Diff:
---
 gcc/gimple-range.cc             | 2 +-
 gcc/testsuite/gcc.dg/pr100521.c | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index e94bb355de3..5b288d8e6a7 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -737,7 +737,7 @@ range_of_builtin_call (range_query &query, irange &r, gcall *call)
 
       query.range_of_expr (r, arg, call);
       // From clz of minimum we can compute result maximum.
-      if (r.constant_p ())
+      if (r.constant_p () && !r.varying_p ())
 	{
 	  int newmaxi = prec - 1 - wi::floor_log2 (r.lower_bound ());
 	  // Argument is unsigned, so do nothing if it is [0, ...] range.
diff --git a/gcc/testsuite/gcc.dg/pr100521.c b/gcc/testsuite/gcc.dg/pr100521.c
new file mode 100644
index 00000000000..fd9f0db5412
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100521.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int
+__builtin_clz (int a)
+{
+  return __builtin_clz(a);
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-12 21:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12 21:03 [gcc r12-755] Skip out on processing __builtin_clz when varying Aldy Hernandez

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).