[v3,2/7] ifcvt: Allow constants for noce_convert_multiple.

Message ID 20211206184352.42264-3-rdapp@linux.ibm.com
State New
Headers
Series ifcvt: Convert multiple |

Commit Message

Robin Dapp Dec. 6, 2021, 6:43 p.m. UTC
  This lifts the restriction of not allowing constants for
noce_convert_multiple.  The code later checks if a valid sequence
is produced anyway.
---
 gcc/ifcvt.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
  

Comments

Jeff Law Dec. 8, 2021, 11:51 p.m. UTC | #1
On 12/6/2021 11:43 AM, Robin Dapp via Gcc-patches wrote:
> This lifts the restriction of not allowing constants for
> noce_convert_multiple.  The code later checks if a valid sequence
> is produced anyway.
> ---
>   gcc/ifcvt.c | 13 ++++++++-----
>   1 file changed, 8 insertions(+), 5 deletions(-)
Fine with a ChangeLog once the prereqs are approved.

jeff
  
Robin Dapp Jan. 10, 2022, 11:17 a.m. UTC | #2
Posting the ChangeLog before pushing.

--

gcc/ChangeLog:

	* ifcvt.c (noce_convert_multiple_sets): Allow constants.
	(bb_ok_for_noce_convert_multiple_sets): Likewise.
  

Patch

diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index c98668d5646..4642176957e 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -3282,7 +3282,9 @@  noce_convert_multiple_sets (struct noce_if_info *if_info)
 	 we'll end up trying to emit r4:HI = cond ? (r1:SI) : (r3:HI).
 	 Wrap the two cmove operands into subregs if appropriate to prevent
 	 that.  */
-      if (GET_MODE (new_val) != GET_MODE (temp))
+
+      if (!CONSTANT_P (new_val)
+	  && GET_MODE (new_val) != GET_MODE (temp))
 	{
 	  machine_mode src_mode = GET_MODE (new_val);
 	  machine_mode dst_mode = GET_MODE (temp);
@@ -3293,7 +3295,8 @@  noce_convert_multiple_sets (struct noce_if_info *if_info)
 	    }
 	  new_val = lowpart_subreg (dst_mode, new_val, src_mode);
 	}
-      if (GET_MODE (old_val) != GET_MODE (temp))
+      if (!CONSTANT_P (old_val)
+	  && GET_MODE (old_val) != GET_MODE (temp))
 	{
 	  machine_mode src_mode = GET_MODE (old_val);
 	  machine_mode dst_mode = GET_MODE (temp);
@@ -3435,9 +3438,9 @@  bb_ok_for_noce_convert_multiple_sets (basic_block test_bb)
       if (!REG_P (dest))
 	return false;
 
-      if (!(REG_P (src)
-	   || (GET_CODE (src) == SUBREG && REG_P (SUBREG_REG (src))
-	       && subreg_lowpart_p (src))))
+      if (!((REG_P (src) || CONSTANT_P (src))
+	    || (GET_CODE (src) == SUBREG && REG_P (SUBREG_REG (src))
+	      && subreg_lowpart_p (src))))
 	return false;
 
       /* Destination must be appropriate for a conditional write.  */