On 08/20/2015 04:34 AM, Richard Sandiford wrote:
Several pieces of code want to know whether all elements of a CONST_VECTOR are equal, and I'm about to add some more to simplify-rtx.c. This patch adds some utility functions for that.I don't think we're really helping ourselves by having the shift amount in "v16qi << 3" be: (const_vector:V16QI [ (const_int 3) (const_int 3) (const_int 3) (const_int 3) (const_int 3) (const_int 3) (const_int 3) (const_int 3) (const_int 3) (const_int 3) (const_int 3) (const_int 3) (const_int 3) (const_int 3) (const_int 3) (const_int 3) ]) so I wanted to leave open the possibility of using: (const:V16QI (vec_duplicate:V16QI (const_int 3))) in future. The interface therefore passes back the duplicated element rather than leaving callers to use CONST_VECTOR_ELT (c, 0) (== XVECEXP (c, 0, 0)). unwrap_const_vec_duplicate is mostly for code that handles vector operations equivalently to scalar ops. The follow-on simplify-rtx.c code makes more use of this. It also came in useful for the tilegx/ tilepro predicates. Tested on x86_64-linux-gnu, arm-linux-gnueabi and aarch64-linux-gnu. I also built cross-compilers for s390x-linux-gnu, spu-elf, tilepro-elf and tilegx-elf and checked by hand that the affected code still worked. (Well, except for the SPU case. That's handling vector constants in which the elements are symbolic addresses, such as { &foo, &foo, &foo, &foo }. Such vectors don't seem to be treated as constants at the gimple level and the initial rtl code that we generate is too complex for later optimisations to convert back to a constant, so I wasn't sure how best to trigger it.) OK to install? Thanks, Richard gcc/ * rtl.h (rtvec_all_equal_p): Declare. (const_vec_duplicate_p, unwrap_const_vec_duplicate): New functions. * rtl.c (rtvec_all_equal_p): New function. * expmed.c (expand_mult): Use unwrap_const_vec_duplicate. * config/aarch64/aarch64.c (aarch64_vect_float_const_representable_p) (aarch64_simd_dup_constant): Use const_vec_duplicate_p. * config/arm/arm.c (neon_vdup_constant): Likewise. * config/s390/s390.c (s390_contiguous_bitmask_vector_p): Likewise. * config/tilegx/constraints.md (W, Y): Likewise. * config/tilepro/constraints.md (W, Y): Likewise. * config/spu/spu.c (spu_legitimate_constant_p): Likewise. (classify_immediate): Use unwrap_const_vec_duplicate. * config/tilepro/predicates.md (reg_or_v4s8bit_operand): Likewise. (reg_or_v2s8bit_operand): Likewise. * config/tilegx/predicates.md (reg_or_v8s8bit_operand): Likewise. (reg_or_v4s8bit_operand): Likewise.
OK. Jeff
