Skip to content
Snippets Groups Projects
Commit f896c134 authored by Takayuki 'January June' Suwa's avatar Takayuki 'January June' Suwa Committed by Max Filippov
Browse files

xtensa: Fix out-of-bounds array access in the movdi pattern

The following new warnings were introduced in the commit
4f3f0296 ("xtensa: Prepare the transition from Reload to LRA"):

gcc/config/xtensa/xtensa.md:945:26: error: array subscript 3 is above
	array bounds of 'rtx_def* [2]' [-Werror=array-bounds]
  945 |           emit_move_insn (operands[2], operands[3]);
gcc/config/xtensa/xtensa.md:945:26: error: array subscript 2 is above
	array bounds of 'rtx_def* [2]' [-Werror=array-bounds]
  945 |           emit_move_insn (operands[2], operands[3]);

From gcc/insn-emit.cc (generated by building):

> /* ../../gcc/config/xtensa/xtensa.md:932 */
> rtx
> gen_movdi (rtx operand0,
> 	rtx operand1)
> {
>   rtx_insn *_val = 0;
>   start_sequence ();
>   {
>     rtx operands[2];					// only 2 elements
>     operands[0] = operand0;
>     operands[1] = operand1;
> #define FAIL return (end_sequence (), _val)
> #define DONE return (_val = get_insns (), end_sequence (), _val)
> #line 936 "../../gcc/config/xtensa/xtensa.md"
> {
>   if (CONSTANT_P (operands[1]))
>     {
>       /* Split in halves if 64-bit Const-to-Reg moves
> 	 because of offering further optimization opportunities.  */
>       if (register_operand (operands[0], DImode))
> 	{
> 	  xtensa_split_DI_reg_imm (operands);		// out-of-bounds!
> 	  emit_move_insn (operands[0], operands[1]);
> 	  emit_move_insn (operands[2], operands[3]);	// out-of-bounds!
> 	  DONE;
> 	}

gcc/ChangeLog:

	* config/xtensa/xtensa.md (movdi):
	Copy operands[0...1] to ops[0...3] and then use the latter before
	calling xtensa_split_DI_reg_imm() and emitting insns.
parent 82e629c2
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment