diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2015-08-20 19:04:34 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2015-08-20 19:04:34 +0000 |
commit | 92695fbb294bf7fe051041e3143f51c37cc22f82 (patch) | |
tree | 88a816e3cb8340cc79bfdf29195dc3a1e20fd9e6 /gcc/rtl.c | |
parent | c629c24604222d7b3a8e6c8a5010f4f3d2a1b1a6 (diff) | |
download | gcc-92695fbb294bf7fe051041e3143f51c37cc22f82.zip gcc-92695fbb294bf7fe051041e3143f51c37cc22f82.tar.gz gcc-92695fbb294bf7fe051041e3143f51c37cc22f82.tar.bz2 |
rtl.h (rtvec_all_equal_p): Declare.
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.
From-SVN: r227041
Diffstat (limited to 'gcc/rtl.c')
-rw-r--r-- | gcc/rtl.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -657,6 +657,31 @@ rtx_equal_p (const_rtx x, const_rtx y) return 1; } +/* Return true if all elements of VEC are equal. */ + +bool +rtvec_all_equal_p (const_rtvec vec) +{ + const_rtx first = RTVEC_ELT (vec, 0); + /* Optimize the important special case of a vector of constants. + The main use of this function is to detect whether every element + of CONST_VECTOR is the same. */ + switch (GET_CODE (first)) + { + CASE_CONST_UNIQUE: + for (int i = 1, n = GET_NUM_ELEM (vec); i < n; ++i) + if (first != RTVEC_ELT (vec, i)) + return false; + return true; + + default: + for (int i = 1, n = GET_NUM_ELEM (vec); i < n; ++i) + if (!rtx_equal_p (first, RTVEC_ELT (vec, i))) + return false; + return true; + } +} + /* Return an indication of which type of insn should have X as a body. In generator files, this can be UNKNOWN if the answer is only known at (GCC) runtime. Otherwise the value is CODE_LABEL, INSN, CALL_INSN |