https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125859

            Bug ID: 125859
           Summary: promote_duplicated_reg (HImode, val) doesn't work
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
  Target Milestone: ---
            Target: x86

promote_duplicated_reg_to_size has

static rtx
promote_duplicated_reg_to_size (rtx val, int size_needed, int desired_align,
                                int align)
{
  rtx promoted_val;

  if (TARGET_64BIT
      && (size_needed > 4 || (desired_align > align && desired_align > 4)))
    promoted_val = promote_duplicated_reg (DImode, val);
  else if (size_needed > 2 || (desired_align > align && desired_align > 2))
    promoted_val = promote_duplicated_reg (SImode, val);
  else if (size_needed > 1 || (desired_align > align && desired_align > 1))
    promoted_val = promote_duplicated_reg (HImode, val); 
  else  
    promoted_val = val;

  return promoted_val;
}

But promote_duplicated_reg doesn't support HImode:

static rtx
promote_duplicated_reg (machine_mode mode, rtx val)
{
  if (val == const0_rtx)
    return copy_to_mode_reg (mode, CONST0_RTX (mode));

  machine_mode valmode = GET_MODE (val);
  if (GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
    {
      /* Duplicate the scalar value for integer vector.  */
      gcc_assert ((val == const0_rtx || val == constm1_rtx)
                  || GET_MODE_INNER (mode) == valmode);
      rtx dup = gen_reg_rtx (mode);
      bool ok = ix86_expand_vector_init_duplicate (false, mode, dup,
                                                   val);
      gcc_assert (ok);
      return dup;
    }

  rtx tmp;
  int nops = mode == DImode ? 3 : 2;

  gcc_assert (mode == SImode || mode == DImode);
  if (CONST_INT_P (val))
    {
      HOST_WIDE_INT v = INTVAL (val) & 255;

      v |= v << 8;
      v |= v << 16;
      if (mode == DImode)
        v |= (v << 16) << 16;
      return copy_to_mode_reg (mode, gen_int_mode (v, mode));
    }
....

Reply via email to