gimple_range_fold makes an assumption that if there is a LHS on a call that it is an ssa_name.  Especially later in compilation that may not be true.

This patch merely avoids calling routines that assume an ssa-name is being passed in.

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

Andrew

From cef90b0558032b64b021054370ad5b96f8a5c5d8 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacl...@redhat.com>
Date: Wed, 12 Jun 2024 09:20:20 -0400
Subject: [PATCH 1/7] Do not assume LHS of call is an ssa-name.

gimple_range_fold makes an assumption that the LHS of a call is an
ssa_name, which later in compilation may not be true.

	* gimple-range-fold.cc (fold_using_range::range_of_call): Ensure
	LHS is an SSA_NAME before invoking gimple_range_global.
---
 gcc/gimple-range-fold.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 6037c29ce11..52fc3f2cb04 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -1105,7 +1105,7 @@ fold_using_range::range_of_call (vrange &r, gcall *call, fur_source &)
     }
 
   // If there is an LHS, intersect that with what is known.
-  if (lhs)
+  if (gimple_range_ssa_p (lhs))
     {
       Value_Range def (TREE_TYPE (lhs));
       gimple_range_global (def, lhs);
-- 
2.45.0

Reply via email to