[RFC] combine: Handle zero_extend without subreg in change_zero_ext.

Dominik Vogt vogt@linux.vnet.ibm.com
Thu Jan 5 16:46:00 GMT 2017


The attached patch deals with another type of zero_extend that is
not yet handled in change_zero_ext, i.e. (zero_extend
(pseudoreg)), without a "subreg" in between.  What do you think?
(Mostly untested yet.)

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany
-------------- next part --------------
>From 36be099953903aa16ec1f307f0018a3e537638a5 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Thu, 5 Jan 2017 17:37:37 +0100
Subject: [PATCH] combine: Handle zero_extend without subreg in
 change_zero_ext.

Try replacing

  (zero_extend (reg))

with

  (and (subreg (reg) 0)
       (const_int))
---
 gcc/combine.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gcc/combine.c b/gcc/combine.c
index e77f203..b5131b8 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -11372,6 +11372,16 @@ change_zero_ext_src (subrtx_ptr_iterator *piter)
   else if (GET_CODE (x) == ZERO_EXTEND
 	   && SCALAR_INT_MODE_P (mode)
 	   && REG_P (XEXP (x, 0))
+	   && !HARD_REGISTER_P (XEXP (x, 0))
+	   && GET_MODE_PRECISION (GET_MODE (XEXP (x, 0)))
+	      < GET_MODE_PRECISION (mode))
+    {
+      /* (zero_extract (reg)) -> (and (subreg (reg) 0) (const_int)) */
+      x = gen_lowpart_SUBREG (mode, XEXP (x, 0));
+    }
+  else if (GET_CODE (x) == ZERO_EXTEND
+	   && SCALAR_INT_MODE_P (mode)
+	   && REG_P (XEXP (x, 0))
 	   && HARD_REGISTER_P (XEXP (x, 0))
 	   && can_change_dest_mode (XEXP (x, 0), 0, mode))
     {
-- 
2.3.0

-------------- next part --------------
gcc/ChangeLog-change_zero_ext-5

	* combine.c (change_zero_ext_src): Handle zero_extend without subreg.


More information about the Gcc-patches mailing list