This is the mail archive of the gcc@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]

rfc: convert scalar literals to vector constants


I'm taking a look at PR7277, an x86 failure.

The code that triggers the ICE is:

typedef int v8qi __attribute__ ((mode(V8QI)));

	v8qi null(void)
	{
	        return (v8qi) 0LL;
	}

Do we even support casting scalars into vectors? I doubt it, but we should at least make an exception for the 0 constant.

The ICE happens because convert_mode() gets a hold of 0LL and passes it directly to emit_move_insn because it is a constant:

  if (to_mode == from_mode
      || (from_mode == VOIDmode && CONSTANT_P (from)))
    {
      emit_move_insn (to, from);
      return;
    }

ix86_expand_vector_move will move the 0 into memory like thus:

  /* Force constants other than zero into memory.  We do not know how
     the instructions used to build constants modify the upper 64 bits
     of the register, once we have that information we may be able
     to handle some of them more efficiently.  */
  if ((reload_in_progress | reload_completed) == 0
      && register_operand (operands[0], mode)
      && CONSTANT_P (operands[1]) && operands[1] != CONST0_RTX (mode))
    operands[1] = validize_mem (force_const_mem (mode, operands[1]));

Which means that we end up with a constant pool with a scalar 0, but a vector mode. Later, while dumping the constant pool we ICE because we can only handle CONST_VECTOR codes.

What I suggest is fixing convert_mode() to convert scalar 0 into vector 0. Is this an appropriate solution?

I also suggest specifying in the docs that a cast to a scalar constant that is not 0 is undefined.

Aldy


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