diff mbox series

[COMMITTED] Check for constant builtin value first.

Message ID 5b21fcee-9718-e550-eccc-17e228912141@redhat.com
State New
Headers show
Series [COMMITTED] Check for constant builtin value first. | expand

Commit Message

Andrew MacLeod Nov. 3, 2021, 2:39 p.m. UTC
For some reason the original code which folded built_in_constant_p 
always returned [0,0] after inlining...   This patch simply has it check 
if its a constant first, then the check for after inlining.  This 
resolves the testcase forwprop-29.c when ranger is used as the vrp1 pass.

Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed.

Andrew
diff mbox series

Patch

From b18394ce15639489a91a502d3b9db30d73898191 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Mon, 1 Nov 2021 16:20:59 -0400
Subject: [PATCH 3/6] Check for constant builtin value first.

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 | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 2fab904e6b0..6cc7753a750 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -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:
-- 
2.17.2