Hi!

As reported in PR93312, the:
> > > > > >         * config/arm/arm.c (clear_operation_p): New function.
change broke RTL checking bootstrap.

On the testcase from the PR (which is distilled from libgcc2.c, so I think
we don't need to add it into testsuite) we ICE because SET_DEST (elt) is
not a REG, but SUBREG.  The code uses REGNO on it, which is invalid, but
only stores it into a variable, then performs REG_P (reg) check,
determines it is not a REG and bails early.

The following patch just moves the regno variable initialization after that
check, it isn't used in between.  And, as a small optimization, because
reg doesn't change, doesn't use REGNO (reg) a second time to set last_regno.

Ok for trunk if it passes bootstrap/regtest?

2020-01-17  Jakub Jelinek  <ja...@redhat.com>

        PR target/93312
        * config/arm/arm.c (clear_operation_p): Don't use REGNO until
        after checking the argument is a REG.  Don't use REGNO (reg)
        again to set last_regno, reuse regno variable instead.

--- gcc/config/arm/arm.c.jj     2020-01-17 09:31:28.594195284 +0100
+++ gcc/config/arm/arm.c        2020-01-17 19:30:47.747756756 +0100
@@ -13779,7 +13779,6 @@ clear_operation_p (rtx op, bool vfp)
        return false;
 
       reg = SET_DEST (elt);
-      regno = REGNO (reg);
       zero = SET_SRC (elt);
 
       if (!REG_P (reg)
@@ -13787,6 +13786,8 @@ clear_operation_p (rtx op, bool vfp)
          || zero != CONST0_RTX (SImode))
        return false;
 
+      regno = REGNO (reg);
+
       if (vfp)
        {
          if (i != 1 && regno != last_regno + 1)
@@ -13800,7 +13801,7 @@ clear_operation_p (rtx op, bool vfp)
            return false;
        }
 
-      last_regno = REGNO (reg);
+      last_regno = regno;
     }
 
   return true;


        Jakub

Reply via email to