From 16debfadbd759f9933b4a62029661f01188ad928 Mon Sep 17 00:00:00 2001
From: Andrew Pinski <pinskia@gmail.com>
Date: Mon, 5 Dec 2022 09:09:52 +0100
Subject: [PATCH 261/547] tree-optimization/107956 - ICE with NULL call LHS

The following adds a missing check for a NULL call LHS in the
vector pattern recognizer.

	PR tree-optimization/107956
	* tree-vect-patterns.cc (vect_recog_mask_conversion_pattern):
	Check for NULL LHS on masked loads.

(cherry picked from commit 5c11d748564c7ce3b096e87ad350fcddd493e45e)
---
 gcc/tree-vect-patterns.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index 217bdfd7045..6c157b93eb1 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -4603,6 +4603,8 @@ vect_recog_mask_conversion_pattern (vec_info *vinfo,
       else
 	{
 	  lhs = gimple_call_lhs (last_stmt);
+	  if (!lhs)
+	    return NULL;
 	  vectype1 = get_vectype_for_scalar_type (vinfo, TREE_TYPE (lhs));
 	}
 
-- 
2.25.1

