[gcc r16-9461] s390: Fix s390_canonicalize_comparison
Stefan Schulze Frielinghaus via Gcc-cvs <[email protected]> Thu, 30 Jul 2026 10:53:59 +0000 (GMT)
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:933b4f9df15ff89bb7f989b07cb0285cf7ec2d54 commit r16-9461-g933b4f9df15ff89bb7f989b07cb0285cf7ec2d54 Author: Stefan Schulze Frielinghaus <[email protected]> Date: Wed Jul 29 07:40:44 2026 +0200 s390: Fix s390_canonicalize_comparison 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. (cherry picked from commit 8bfaf339d53e6cc2d78a36c0014161e55cafbd5a) Diff: --- gcc/config/s390/s390.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 18840b5080f6..edcd39c171af 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -1807,7 +1807,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) { @@ -1834,7 +1834,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)) { @@ -1870,6 +1870,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) @@ -1893,6 +1894,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) @@ -1929,6 +1931,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)) {