This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, combine]: Fix PR84123: internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c


Hello!

As shown in the PR, alpha specific testcase hits the above ICE when
combine pass is trying to simplify:

(insn 13 12 16 2 (set (reg:SI 141 [ ID ])
        (zero_extend:SI (subreg:QI (reg:DI 48 $f16 [ ID ]) 0))) 48
{zero_extendqisi2}

via change_zero_ext (combine.c):

11486         else if (GET_CODE (x) == ZERO_EXTEND
11487                  && GET_CODE (XEXP (x, 0)) == SUBREG
11488                  && SCALAR_INT_MODE_P (GET_MODE (SUBREG_REG
(XEXP (x, 0))))
11489                  && !paradoxical_subreg_p (XEXP (x, 0))
11490                  && subreg_lowpart_p (XEXP (x, 0)))
11491           {
11492             inner_mode = as_a <scalar_int_mode> (GET_MODE (XEXP (x, 0)));
11493             size = GET_MODE_PRECISION (inner_mode);
11494             x = SUBREG_REG (XEXP (x, 0));
11495             if (GET_MODE (x) != mode)
11496               x = gen_lowpart_SUBREG (mode, x);
11497           }

This won't work when x in line 11496 is a hard register and mode is
unsupported with targetm.hard_regno_mode_ok.

(gdb) p debug_rtx (x)
(reg:DI 48 $f16 [ ID ])
$1 = void
(gdb) p mode
$2 = {m_mode = E_SImode}

(which in case of alpha is defined as:

--cut here--
/* Implement TARGET_HARD_REGNO_MODE_OK.  On Alpha, the integer registers
   can hold any mode.  The floating-point registers can hold 64-bit
   integers as well, but not smaller values.  */

static bool
alpha_hard_regno_mode_ok (unsigned int regno, machine_mode mode)
{
  if (IN_RANGE (regno, 32, 62))
    return (mode == SFmode
   || mode == DFmode
   || mode == DImode
   || mode == SCmode
   || mode == DCmode);
  return true;
}
--cut here--

We should skip RTXes that will result in certain ICE here, and this is
what the attached patch does.

2018-01-31  Uros Bizjak  <ubizjak@gmail.com>

    PR target/84123
    * combine.c (change_zero_ext): Check if hard register satisfies
    can_change_dest_mode before calling gen_lowpart_SUBREG.

Patch was bootstrapped and regression tested on alphaev68-linux-gnu
(native bootstrap) and x86_64-linux-gnu {,-m32}.

OK for mainline and backports?

Uros.

Attachment: p.diff.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]