From d39fbed75810fc7478842503ecb0268b85dc9c2e Mon Sep 17 00:00:00 2001
From: Uros Bizjak <ubizjak@gmail.com>
Date: Tue, 18 May 2021 15:45:54 +0200
Subject: [PATCH] i386: Fix split_double_mode with paradoxical subreg
 [PR100626]
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

split_double_mode calls simplify_gen_subreg, which fails for the
high half of the paradoxical subreg.  Return temporary register
instead of NULL RTX in this case.

2021-05-18  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
	PR target/100626
	* config/i386/i386-expand.c (split_double_mode): Return
	temporary register when simplify_gen_subreg fails with
	the high half od the paradoxical subreg.
---
 gcc/config/i386/i386-expand.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
index 0fa8d45a684e..9f3d41955a2f 100644
--- a/gcc/config/i386/i386-expand.c
+++ b/gcc/config/i386/i386-expand.c
@@ -154,9 +154,13 @@ split_double_mode (machine_mode mode, rtx operands[],
 	  lo_half[num] = simplify_gen_subreg (half_mode, op,
 					      GET_MODE (op) == VOIDmode
 					      ? mode : GET_MODE (op), 0);
-	  hi_half[num] = simplify_gen_subreg (half_mode, op,
-					      GET_MODE (op) == VOIDmode
-					      ? mode : GET_MODE (op), byte);
+
+	  rtx tmp = simplify_gen_subreg (half_mode, op,
+					 GET_MODE (op) == VOIDmode
+					 ? mode : GET_MODE (op), byte);
+	  /* simplify_gen_subreg will return NULL RTX for the
+	     high half of the paradoxical subreg. */
+	  hi_half[num] = tmp ? tmp : gen_reg_rtx (half_mode);
 	}
     }
 }
-- 
GitLab