[rtl, i386] vec_merge simplification

Eric Botcazou ebotcazou@adacore.com
Wed Mar 27 09:49:00 GMT 2013

> int is getting small to store one bit per vector element (V32QI...) so I
> switched to hwint after checking that Zadeck's patches don't touch this.

unsigned HOST_WIDE_INT is indeed the correct type to use for mask manipulation 
but please use UINTVAL instead of INTVAL with it.  And:

+	  unsigned HOST_WIDE_INT mask = (HOST_WIDE_INT_1 << n_elts) - 1;

can be flagged as relying on undefined behavior (we fixed a bunch of cases a 
couple of years ago) so use:

  unsigned HOST_WIDE_INT mask = ((unsigned HOST_WIDE_INT) 1 << n_elts) - 1;

> Bootstrap + testsuite on x86_64-linux-gnu.
> 2013-03-17  Marc Glisse  <marc.glisse@inria.fr>
> gcc/
>  	* simplify-rtx.c (simplify_binary_operation_1) <VEC_SELECT>:
>  	Handle VEC_MERGE.
>  	(simplify_ternary_operation) <VEC_MERGE>: Handle nested VEC_MERGE.
>  	Handle equal arguments.

OK, modulo a few nits:

 - in simplify_binary_operation_1, the notion of left and right is a bit 
elusive, so I'd use all_operand0 and all_operand1 instead.  And I'd use the 
same idiom as in simplify_ternary_operation: (sel & (1 << UINTVAL (j)).

 - in simplify_ternary_operation, we probably need to test that op0 doesn't 
have side-effects too before dropping one of the copies, as VEC_MERGE is 
supposed to evaluate its 2 arguments I think.

Eric Botcazou

More information about the Gcc-patches mailing list