[Committed] Avoid duplicate vector initializations in initial RTL

Roger Sayle roger@eyesopen.com
Mon Apr 10 05:16:00 GMT 2006


The following patch is a minor one-line tweak to store_constructor
in expr.c.  Investigating the initial RTL we generate for vector
initializers, I noticed that many vectors are initialized twice.
This issue is that the middle-end is setting a vector to zero (for
the benefit of CSE/flow etc...) even if then proceeds to call
vec_init_optab with an explicit initializer.  This results in the
vector getting initialized once to zero by the middle-end, and then
again to the correct value by the backend.  The documentation of
vec_init doesn't mention that the vector is guaranteed to already
have been initialized to zero, and like "mov" insns, the backends
don't/shouldn't take advantage of this.  The patch below decreases
the amount of junk RTL we produce, that needs to be cleaned up
later by CSE and friends.

The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", all default languages including Ada, and regression
tested with a top-level "make -k check" with no new failures.

Commited to mainline as revision 112817.



2006-04-09  Roger Sayle  <roger@eyesopen.com>

	* expr.c (store_constructor): Don't bother clearing target if
	we're about to assign a vector to it using vec_init_optab.


Index: expr.c
===================================================================
*** expr.c	(revision 112734)
--- expr.c	(working copy)
*************** store_constructor (tree exp, rtx target,
*** 5325,5331 ****
  	  }

  	/* Inform later passes that the old value is dead.  */
! 	if (!cleared && REG_P (target))
  	  emit_move_insn (target, CONST0_RTX (GET_MODE (target)));

          /* Store each element of the constructor into the corresponding
--- 5325,5331 ----
  	  }

  	/* Inform later passes that the old value is dead.  */
! 	if (!cleared && !vector && REG_P (target))
  	  emit_move_insn (target, CONST0_RTX (GET_MODE (target)));

          /* Store each element of the constructor into the corresponding

Roger
--



More information about the Gcc-patches mailing list