]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
s390: Fix s390_canonicalize_comparison
authorStefan Schulze Frielinghaus <stefansf@gcc.gnu.org>
Wed, 29 Jul 2026 05:40:44 +0000 (07:40 +0200)
committerStefan Schulze Frielinghaus <stefansf@gcc.gnu.org>
Wed, 29 Jul 2026 05:40:44 +0000 (07:40 +0200)
Combine may come up with insns of the form:

Trying 230 -> 231:
  230: %cc:CCZ=unspec[r82:DF,0xfc0]TDC_INSN
  231: r83:SI=unspec[%cc:CCZ]CC_TO_INT
      REG_DEAD %cc:CCZ
Failed to match this instruction:
(set (reg:SI 83 [ _38 ])
    (unspec:SI [
            (unspec:CCZ [
                    (reg:DF 82 [ _37 ])
                    (const_int 4032 [0xfc0])
                ] UNSPEC_TDC_INSN)
        ] UNSPEC_CC_TO_INT))

where the operand for UNSPEC_CC_TO_INT is not a register.  Deal with
this during s390_canonicalize_comparison.

While on it canonicalize GET_CODE (x) == REG to REG_P (x).

gcc/ChangeLog:

* config/s390/s390.cc (s390_canonicalize_comparison): Verify op0
for an UNSPEC_CC_TO_INT is a register.

gcc/config/s390/s390.cc

index 955cf1ebd6035bf00e360ae67f49703b6e70c2c3..038eb57759ef7bc5c09ab4395d8790bdd6492d87 100644 (file)
@@ -1796,7 +1796,7 @@ s390_canonicalize_comparison (int *code, rtx *op0, rtx *op1,
       && XINT (*op0, 1) == UNSPEC_STRCMPCC_TO_INT
       && XVECLEN (*op0, 0) == 1
       && GET_MODE (XVECEXP (*op0, 0, 0)) == CCUmode
-      && GET_CODE (XVECEXP (*op0, 0, 0)) == REG
+      && REG_P (XVECEXP (*op0, 0, 0))
       && REGNO (XVECEXP (*op0, 0, 0)) == CC_REGNUM
       && *op1 == const0_rtx)
     {
@@ -1823,7 +1823,7 @@ s390_canonicalize_comparison (int *code, rtx *op0, rtx *op1,
   if (GET_CODE (*op0) == UNSPEC
       && XINT (*op0, 1) == UNSPEC_CC_TO_INT
       && XVECLEN (*op0, 0) == 1
-      && GET_CODE (XVECEXP (*op0, 0, 0)) == REG
+      && REG_P (XVECEXP (*op0, 0, 0))
       && REGNO (XVECEXP (*op0, 0, 0)) == CC_REGNUM
       && CONST_INT_P (*op1))
     {
@@ -1859,6 +1859,7 @@ s390_canonicalize_comparison (int *code, rtx *op0, rtx *op1,
       && GET_CODE (XEXP (*op0, 0)) == UNSPEC
       && XINT (XEXP (*op0, 0), 1) == UNSPEC_CC_TO_INT
       && XVECLEN (XEXP (*op0, 0), 0) == 1
+      && REG_P (XVECEXP (XEXP (*op0, 0), 0, 0))
       && REGNO (XVECEXP (XEXP (*op0, 0), 0, 0)) == CC_REGNUM
       && CONST_INT_P (XEXP (*op0, 1))
       && CONST_INT_P (*op1)
@@ -1882,6 +1883,7 @@ s390_canonicalize_comparison (int *code, rtx *op0, rtx *op1,
       && GET_CODE (XEXP (*op0, 0)) == UNSPEC
       && XINT (XEXP (*op0, 0), 1) == UNSPEC_CC_TO_INT
       && XVECLEN (XEXP (*op0, 0), 0) == 1
+      && REG_P (XVECEXP (XEXP (*op0, 0), 0, 0))
       && REGNO (XVECEXP (XEXP (*op0, 0), 0, 0)) == CC_REGNUM
       && CONST_INT_P (XEXP (*op0, 1))
       && CONST_INT_P (*op1)
@@ -1918,6 +1920,7 @@ s390_canonicalize_comparison (int *code, rtx *op0, rtx *op1,
       if (GET_CODE (*op0) == UNSPEC
          && XINT (*op0, 1) == UNSPEC_CC_TO_INT
          && XVECLEN (*op0, 0) == 1
+         && REG_P (XVECEXP (*op0, 0, 0))
          && REGNO (XVECEXP (*op0, 0, 0)) == CC_REGNUM
          && CONST_INT_P (*op1))
        {