]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Check for constant builtin value first.
authorAndrew MacLeod <amacleod@redhat.com>
Mon, 1 Nov 2021 20:20:59 +0000 (16:20 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Wed, 3 Nov 2021 14:13:32 +0000 (10:13 -0400)
The original code imported from EVRP for evaluating built_in_constant_p
didn't check to see if the value was a constant before checking the
inlining flag.  Now we check for a constant first.

* gimple-range-fold.cc (fold_using_range::range_of_builtin_call): Test
for constant before any other processing.

gcc/gimple-range-fold.cc

index 2fab904e6b099a64ed5dfe00c0137e940db69be2..6cc7753a750d492e7aac2d0f90be70148b972b3b 100644 (file)
@@ -960,18 +960,18 @@ fold_using_range::range_of_builtin_call (irange &r, gcall *call,
   switch (func)
     {
     case CFN_BUILT_IN_CONSTANT_P:
-      if (cfun->after_inlining)
-       {
-         r.set_zero (type);
-         // r.equiv_clear ();
-         return true;
-       }
       arg = gimple_call_arg (call, 0);
       if (src.get_operand (r, arg) && r.singleton_p ())
        {
          r.set (build_one_cst (type), build_one_cst (type));
          return true;
        }
+      if (cfun->after_inlining)
+       {
+         r.set_zero (type);
+         // r.equiv_clear ();
+         return true;
+       }
       break;
 
     case CFN_BUILT_IN_TOUPPER: