This is the mail archive of the 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] use integer types for copies in SRA when mode is not BLK

I (and other) noticed that we produce worse code in 4.0.0 and on the mainline
than 3.4.0 for the following code:
struct s
int i1:1;
int i2:1;
int i3:1;
void f(struct s *x, struct s *y) { *x = *y; }

We copy the struct element by element which is not a good thing really. There were
two ways to fix this: force SRA to produce a block copy for case where we don't use
any fields or any other usage, the other would change SRA to produce an integer
variable which holds the struct and use VIEW_CONVERT_EXPR. This patch implements
the second idea as we also are able to remove copies at the tree level which would
have been left with the first way.

I did bootstrap and test on powerpc-darwin with no regressions. But there is one
place where I would like to improve before submitting a real patch (besides some
more comments are needed). In scalarize_copy, handle the case where one side is
copy via integer and the other side is block copy.

For the case about we now produce the code which we produced in 3.4.0 and we get
on the tree level (right before expand):
*x = VIEW_CONVERT_EXPR<struct s>(VIEW_CONVERT_EXPR<unsigned int>(*y));

Comments or is this an abuse of VIEW_CONVERT_EXPR?

Andrew Pinski

	* tree-sra.c (enum copy_how): New enum.
	(struct sra_elt): Rename use_block_copy to how_to_copy and change
	the type to enum copy_how.
	(instantiate_element_integer): New function.
	(decide_block_copy): Rename use_block_copy to how_to_copy.
	If the aggregate who's mode is not BLK, then do the copy via integers.
	(generate_copy_inout): Handle copy via integer mode copy.
	(generate_element_zero): Likewise.
	(scalarize_copy): Update uses of use_block_copy to how_to_copy.
	(scalarize_init): Likewise.
	(scalarize_ldst): Handle copy via integer mode copy and update uses of
	use_block_copy to how_to_copy.

Attachment: t5.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]