[gcc/devel/ranger] [rtl] Harden 'set_noop_p' for non-constant selectors [PR94279]

Aldy Hernandez aldyh@gcc.gnu.org
Wed Jun 17 20:52:00 GMT 2020


https://gcc.gnu.org/g:f2c2eaaf8fb5c66ae372bb526b2b2fe67a9c5c39

commit f2c2eaaf8fb5c66ae372bb526b2b2fe67a9c5c39
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Wed Apr 22 16:58:44 2020 +0200

    [rtl] Harden 'set_noop_p' for non-constant selectors [PR94279]
    
    ... given that the GCN target did away with the constant 'vec_select'
    restriction.
    
            gcc/
            PR target/94279
            * rtlanal.c (set_noop_p): Handle non-constant selectors.

Diff:
---
 gcc/ChangeLog |  3 +++
 gcc/rtlanal.c | 12 +++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2ba39f67200..ef851ef8462 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,8 @@
 2020-04-29  Thomas Schwinge  <thomas@codesourcery.com>
 
+	PR target/94279
+	* rtlanal.c (set_noop_p): Handle non-constant selectors.
+
 	PR target/94282
 	* common/config/gcn/gcn-common.c (gcn_except_unwind_info): New
 	function.
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index c7ab86e228b..0ebde7622db 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -1631,12 +1631,18 @@ set_noop_p (const_rtx set)
       int i;
       rtx par = XEXP (src, 1);
       rtx src0 = XEXP (src, 0);
-      poly_int64 c0 = rtx_to_poly_int64 (XVECEXP (par, 0, 0));
+      poly_int64 c0;
+      if (!poly_int_rtx_p (XVECEXP (par, 0, 0), &c0))
+	return 0;
       poly_int64 offset = GET_MODE_UNIT_SIZE (GET_MODE (src0)) * c0;
 
       for (i = 1; i < XVECLEN (par, 0); i++)
-	if (maybe_ne (rtx_to_poly_int64 (XVECEXP (par, 0, i)), c0 + i))
-	  return 0;
+	{
+	  poly_int64 c0i;
+	  if (!poly_int_rtx_p (XVECEXP (par, 0, i), &c0i)
+	      || maybe_ne (c0i, c0 + i))
+	    return 0;
+	}
       return
 	REG_CAN_CHANGE_MODE_P (REGNO (dst), GET_MODE (src0), GET_MODE (dst))
 	&& simplify_subreg_regno (REGNO (src0), GET_MODE (src0),


More information about the Gcc-cvs mailing list