[rs6000]Fix PR92132 by adding vec_cmp and vcond_mask supports
To support full condition reduction vectorization, we have to define vec_cmp* and vcond_mask_*. This patch is to add related expands. Also add the missing vector fp comparison RTL pattern supports like: ungt, unge, unlt, unle, ne, lt and le. gcc/ChangeLog 2019-11-08 Kewen Lin <linkw@gcc.gnu.org> PR target/92132 * config/rs6000/predicates.md (signed_or_equality_comparison_operator): New predicate. (unsigned_or_equality_comparison_operator): Likewise. * config/rs6000/rs6000.md (one_cmpl<mode>2): Remove expand. (one_cmpl<mode>3_internal): Rename to one_cmpl<mode>2. * config/rs6000/vector.md (vcond_mask_<mode><mode> for VEC_I and VEC_I): New expand. (vec_cmp<mode><mode> for VEC_I and VEC_I): Likewise. (vec_cmpu<mode><mode> for VEC_I and VEC_I): Likewise. (vcond_mask_<mode><VEC_int> for VEC_F): New expand for float vector modes and same-size integer vector modes. (vec_cmp<mode><VEC_int> for VEC_F): Likewise. (vector_lt<mode> for VEC_F): New expand. (vector_le<mode> for VEC_F): Likewise. (vector_ne<mode> for VEC_F): Likewise. (vector_unge<mode> for VEC_F): Likewise. (vector_ungt<mode> for VEC_F): Likewise. (vector_unle<mode> for VEC_F): Likewise. (vector_unlt<mode> for VEC_F): Likewise. (vector_uneq<mode>): Expose name. (vector_ltgt<mode>): Likewise. (vector_unordered<mode>): Likewise. (vector_ordered<mode>): Likewise. gcc/testsuite/ChangeLog 2019-11-08 Kewen Lin <linkw@gcc.gnu.org> PR target/92132 * gcc.target/powerpc/pr92132-fp-1.c: New test. * gcc.target/powerpc/pr92132-fp-2.c: New test. * gcc.target/powerpc/pr92132-int-1.c: New test. * gcc.target/powerpc/pr92132-int-2.c: New test. From-SVN: r277947
This commit is contained in:
parent
1aeecaf58f
commit
bc5b2b6881
9 changed files with 1150 additions and 11 deletions
|
@ -1,3 +1,30 @@
|
|||
2019-11-08 Kewen Lin <linkw@gcc.gnu.org>
|
||||
|
||||
PR target/92132
|
||||
* config/rs6000/predicates.md
|
||||
(signed_or_equality_comparison_operator): New predicate.
|
||||
(unsigned_or_equality_comparison_operator): Likewise.
|
||||
* config/rs6000/rs6000.md (one_cmpl<mode>2): Remove expand.
|
||||
(one_cmpl<mode>3_internal): Rename to one_cmpl<mode>2.
|
||||
* config/rs6000/vector.md
|
||||
(vcond_mask_<mode><mode> for VEC_I and VEC_I): New expand.
|
||||
(vec_cmp<mode><mode> for VEC_I and VEC_I): Likewise.
|
||||
(vec_cmpu<mode><mode> for VEC_I and VEC_I): Likewise.
|
||||
(vcond_mask_<mode><VEC_int> for VEC_F): New expand for float
|
||||
vector modes and same-size integer vector modes.
|
||||
(vec_cmp<mode><VEC_int> for VEC_F): Likewise.
|
||||
(vector_lt<mode> for VEC_F): New expand.
|
||||
(vector_le<mode> for VEC_F): Likewise.
|
||||
(vector_ne<mode> for VEC_F): Likewise.
|
||||
(vector_unge<mode> for VEC_F): Likewise.
|
||||
(vector_ungt<mode> for VEC_F): Likewise.
|
||||
(vector_unle<mode> for VEC_F): Likewise.
|
||||
(vector_unlt<mode> for VEC_F): Likewise.
|
||||
(vector_uneq<mode>): Expose name.
|
||||
(vector_ltgt<mode>): Likewise.
|
||||
(vector_unordered<mode>): Likewise.
|
||||
(vector_ordered<mode>): Likewise.
|
||||
|
||||
2019-11-08 Hongtao Liu <Hongtao.liu@intel.com>
|
||||
|
||||
PR target/92295
|
||||
|
|
|
@ -1147,6 +1147,16 @@
|
|||
(define_predicate "signed_comparison_operator"
|
||||
(match_code "lt,gt,le,ge"))
|
||||
|
||||
;; Return 1 if OP is a signed comparison or an equality operator.
|
||||
(define_predicate "signed_or_equality_comparison_operator"
|
||||
(ior (match_operand 0 "equality_operator")
|
||||
(match_operand 0 "signed_comparison_operator")))
|
||||
|
||||
;; Return 1 if OP is an unsigned comparison or an equality operator.
|
||||
(define_predicate "unsigned_or_equality_comparison_operator"
|
||||
(ior (match_operand 0 "equality_operator")
|
||||
(match_operand 0 "unsigned_comparison_operator")))
|
||||
|
||||
;; Return 1 if OP is a comparison operation that is valid for an SCC insn --
|
||||
;; it must be a positive comparison.
|
||||
(define_predicate "scc_comparison_operator"
|
||||
|
|
|
@ -6504,12 +6504,6 @@
|
|||
""
|
||||
"")
|
||||
|
||||
(define_expand "one_cmpl<mode>2"
|
||||
[(set (match_operand:BOOL_128 0 "vlogical_operand")
|
||||
(not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand")))]
|
||||
""
|
||||
"")
|
||||
|
||||
(define_expand "nor<mode>3"
|
||||
[(set (match_operand:BOOL_128 0 "vlogical_operand")
|
||||
(and:BOOL_128
|
||||
|
@ -6804,7 +6798,7 @@
|
|||
(const_string "16")))])
|
||||
|
||||
;; 128-bit one's complement
|
||||
(define_insn_and_split "*one_cmpl<mode>3_internal"
|
||||
(define_insn_and_split "one_cmpl<mode>2"
|
||||
[(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
|
||||
(not:BOOL_128
|
||||
(match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_UNARY>")))]
|
||||
|
|
|
@ -493,6 +493,260 @@
|
|||
FAIL;
|
||||
})
|
||||
|
||||
;; To support vector condition vectorization, define vcond_mask and vec_cmp.
|
||||
|
||||
;; Same mode for condition true/false values and predicate operand.
|
||||
(define_expand "vcond_mask_<mode><mode>"
|
||||
[(match_operand:VEC_I 0 "vint_operand")
|
||||
(match_operand:VEC_I 1 "vint_operand")
|
||||
(match_operand:VEC_I 2 "vint_operand")
|
||||
(match_operand:VEC_I 3 "vint_operand")]
|
||||
"VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
|
||||
{
|
||||
emit_insn (gen_vector_select_<mode> (operands[0], operands[2], operands[1],
|
||||
operands[3]));
|
||||
DONE;
|
||||
})
|
||||
|
||||
;; Condition true/false values are float but predicate operand is of
|
||||
;; type integer vector with same element size.
|
||||
(define_expand "vcond_mask_<mode><VEC_int>"
|
||||
[(match_operand:VEC_F 0 "vfloat_operand")
|
||||
(match_operand:VEC_F 1 "vfloat_operand")
|
||||
(match_operand:VEC_F 2 "vfloat_operand")
|
||||
(match_operand:<VEC_INT> 3 "vint_operand")]
|
||||
"VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
|
||||
{
|
||||
emit_insn (gen_vector_select_<mode> (operands[0], operands[2], operands[1],
|
||||
gen_lowpart (<MODE>mode, operands[3])));
|
||||
DONE;
|
||||
})
|
||||
|
||||
;; For signed integer vectors comparison.
|
||||
(define_expand "vec_cmp<mode><mode>"
|
||||
[(set (match_operand:VEC_I 0 "vint_operand")
|
||||
(match_operator 1 "signed_or_equality_comparison_operator"
|
||||
[(match_operand:VEC_I 2 "vint_operand")
|
||||
(match_operand:VEC_I 3 "vint_operand")]))]
|
||||
"VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
|
||||
{
|
||||
enum rtx_code code = GET_CODE (operands[1]);
|
||||
rtx tmp = gen_reg_rtx (<MODE>mode);
|
||||
switch (code)
|
||||
{
|
||||
case NE:
|
||||
emit_insn (gen_vector_eq<mode> (operands[0], operands[2], operands[3]));
|
||||
emit_insn (gen_one_cmpl<mode>2 (operands[0], operands[0]));
|
||||
break;
|
||||
case EQ:
|
||||
emit_insn (gen_vector_eq<mode> (operands[0], operands[2], operands[3]));
|
||||
break;
|
||||
case GE:
|
||||
emit_insn (gen_vector_nlt<mode> (operands[0],operands[2], operands[3],
|
||||
tmp));
|
||||
break;
|
||||
case GT:
|
||||
emit_insn (gen_vector_gt<mode> (operands[0], operands[2], operands[3]));
|
||||
break;
|
||||
case LE:
|
||||
emit_insn (gen_vector_ngt<mode> (operands[0], operands[2], operands[3],
|
||||
tmp));
|
||||
break;
|
||||
case LT:
|
||||
emit_insn (gen_vector_gt<mode> (operands[0], operands[3], operands[2]));
|
||||
break;
|
||||
default:
|
||||
gcc_unreachable ();
|
||||
break;
|
||||
}
|
||||
DONE;
|
||||
})
|
||||
|
||||
;; For unsigned integer vectors comparison.
|
||||
(define_expand "vec_cmpu<mode><mode>"
|
||||
[(set (match_operand:VEC_I 0 "vint_operand")
|
||||
(match_operator 1 "unsigned_or_equality_comparison_operator"
|
||||
[(match_operand:VEC_I 2 "vint_operand")
|
||||
(match_operand:VEC_I 3 "vint_operand")]))]
|
||||
"VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
|
||||
{
|
||||
enum rtx_code code = GET_CODE (operands[1]);
|
||||
rtx tmp = gen_reg_rtx (<MODE>mode);
|
||||
switch (code)
|
||||
{
|
||||
case NE:
|
||||
emit_insn (gen_vector_eq<mode> (operands[0], operands[2], operands[3]));
|
||||
emit_insn (gen_one_cmpl<mode>2 (operands[0], operands[0]));
|
||||
break;
|
||||
case EQ:
|
||||
emit_insn (gen_vector_eq<mode> (operands[0], operands[2], operands[3]));
|
||||
break;
|
||||
case GEU:
|
||||
emit_insn (gen_vector_nltu<mode> (operands[0], operands[2], operands[3],
|
||||
tmp));
|
||||
break;
|
||||
case GTU:
|
||||
emit_insn (gen_vector_gtu<mode> (operands[0], operands[2], operands[3]));
|
||||
break;
|
||||
case LEU:
|
||||
emit_insn (gen_vector_ngtu<mode> (operands[0], operands[2], operands[3],
|
||||
tmp));
|
||||
break;
|
||||
case LTU:
|
||||
emit_insn (gen_vector_gtu<mode> (operands[0], operands[3], operands[2]));
|
||||
break;
|
||||
default:
|
||||
gcc_unreachable ();
|
||||
break;
|
||||
}
|
||||
DONE;
|
||||
})
|
||||
|
||||
;; For float point vectors comparison.
|
||||
(define_expand "vec_cmp<mode><VEC_int>"
|
||||
[(set (match_operand:<VEC_INT> 0 "vint_operand")
|
||||
(match_operator 1 "comparison_operator"
|
||||
[(match_operand:VEC_F 2 "vfloat_operand")
|
||||
(match_operand:VEC_F 3 "vfloat_operand")]))]
|
||||
"VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
|
||||
{
|
||||
enum rtx_code code = GET_CODE (operands[1]);
|
||||
rtx res = gen_reg_rtx (<MODE>mode);
|
||||
switch (code)
|
||||
{
|
||||
case NE:
|
||||
emit_insn (gen_vector_ne<mode> (res, operands[2], operands[3]));
|
||||
break;
|
||||
case EQ:
|
||||
emit_insn (gen_vector_eq<mode> (res, operands[2], operands[3]));
|
||||
break;
|
||||
case GE:
|
||||
emit_insn (gen_vector_ge<mode> (res, operands[2], operands[3]));
|
||||
break;
|
||||
case GT:
|
||||
emit_insn (gen_vector_gt<mode> (res, operands[2], operands[3]));
|
||||
break;
|
||||
case LE:
|
||||
emit_insn (gen_vector_le<mode> (res, operands[2], operands[3]));
|
||||
break;
|
||||
case LT:
|
||||
emit_insn (gen_vector_lt<mode> (res, operands[2], operands[3]));
|
||||
break;
|
||||
case LTGT:
|
||||
emit_insn (gen_vector_ltgt<mode> (res, operands[2], operands[3]));
|
||||
break;
|
||||
case UNORDERED:
|
||||
emit_insn (gen_vector_unordered<mode> (res, operands[2], operands[3]));
|
||||
break;
|
||||
case ORDERED:
|
||||
emit_insn (gen_vector_ordered<mode> (res, operands[2], operands[3]));
|
||||
break;
|
||||
case UNEQ:
|
||||
emit_insn (gen_vector_uneq<mode> (res, operands[2], operands[3]));
|
||||
break;
|
||||
case UNGE:
|
||||
emit_insn (gen_vector_unge<mode> (res, operands[2], operands[3]));
|
||||
break;
|
||||
case UNGT:
|
||||
emit_insn (gen_vector_ungt<mode> (res, operands[2], operands[3]));
|
||||
break;
|
||||
case UNLE:
|
||||
emit_insn (gen_vector_unle<mode> (res, operands[2], operands[3]));
|
||||
break;
|
||||
case UNLT:
|
||||
emit_insn (gen_vector_unlt<mode> (res, operands[2], operands[3]));
|
||||
break;
|
||||
|
||||
default:
|
||||
gcc_unreachable ();
|
||||
}
|
||||
|
||||
emit_insn (gen_move_insn (operands[0], gen_lowpart (<VEC_INT>mode, res)));
|
||||
DONE;
|
||||
})
|
||||
|
||||
; lt(a,b) = gt(b,a)
|
||||
(define_expand "vector_lt<mode>"
|
||||
[(set (match_operand:VEC_F 0 "vfloat_operand")
|
||||
(lt:VEC_F (match_operand:VEC_F 1 "vfloat_operand")
|
||||
(match_operand:VEC_F 2 "vfloat_operand")))]
|
||||
"VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
|
||||
{
|
||||
emit_insn (gen_vector_gt<mode> (operands[0], operands[2], operands[1]));
|
||||
DONE;
|
||||
})
|
||||
|
||||
; le(a,b) = ge(b,a)
|
||||
(define_expand "vector_le<mode>"
|
||||
[(set (match_operand:VEC_F 0 "vfloat_operand")
|
||||
(le:VEC_F (match_operand:VEC_F 1 "vfloat_operand")
|
||||
(match_operand:VEC_F 2 "vfloat_operand")))]
|
||||
"VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
|
||||
{
|
||||
emit_insn (gen_vector_ge<mode> (operands[0], operands[2], operands[1]));
|
||||
DONE;
|
||||
})
|
||||
|
||||
; ne(a,b) = ~eq(a,b)
|
||||
(define_expand "vector_ne<mode>"
|
||||
[(set (match_operand:VEC_F 0 "vfloat_operand")
|
||||
(ne:VEC_F (match_operand:VEC_F 1 "vfloat_operand")
|
||||
(match_operand:VEC_F 2 "vfloat_operand")))]
|
||||
"VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
|
||||
{
|
||||
emit_insn (gen_vector_eq<mode> (operands[0], operands[1], operands[2]));
|
||||
emit_insn (gen_one_cmpl<mode>2 (operands[0], operands[0]));
|
||||
DONE;
|
||||
})
|
||||
|
||||
; unge(a,b) = ~gt(b,a)
|
||||
(define_expand "vector_unge<mode>"
|
||||
[(set (match_operand:VEC_F 0 "vfloat_operand")
|
||||
(unge:VEC_F (match_operand:VEC_F 1 "vfloat_operand")
|
||||
(match_operand:VEC_F 2 "vfloat_operand")))]
|
||||
"VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
|
||||
{
|
||||
emit_insn (gen_vector_gt<mode> (operands[0], operands[2], operands[1]));
|
||||
emit_insn (gen_one_cmpl<mode>2 (operands[0], operands[0]));
|
||||
DONE;
|
||||
})
|
||||
|
||||
; ungt(a,b) = ~ge(b,a)
|
||||
(define_expand "vector_ungt<mode>"
|
||||
[(set (match_operand:VEC_F 0 "vfloat_operand")
|
||||
(ungt:VEC_F (match_operand:VEC_F 1 "vfloat_operand")
|
||||
(match_operand:VEC_F 2 "vfloat_operand")))]
|
||||
"VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
|
||||
{
|
||||
emit_insn (gen_vector_ge<mode> (operands[0], operands[2], operands[1]));
|
||||
emit_insn (gen_one_cmpl<mode>2 (operands[0], operands[0]));
|
||||
DONE;
|
||||
})
|
||||
|
||||
; unle(a,b) = ~gt(a,b)
|
||||
(define_expand "vector_unle<mode>"
|
||||
[(set (match_operand:VEC_F 0 "vfloat_operand")
|
||||
(unle:VEC_F (match_operand:VEC_F 1 "vfloat_operand")
|
||||
(match_operand:VEC_F 2 "vfloat_operand")))]
|
||||
"VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
|
||||
{
|
||||
emit_insn (gen_vector_gt<mode> (operands[0], operands[1], operands[2]));
|
||||
emit_insn (gen_one_cmpl<mode>2 (operands[0], operands[0]));
|
||||
DONE;
|
||||
})
|
||||
|
||||
; unlt(a,b) = ~ge(a,b)
|
||||
(define_expand "vector_unlt<mode>"
|
||||
[(set (match_operand:VEC_F 0 "vfloat_operand")
|
||||
(unlt:VEC_F (match_operand:VEC_F 1 "vfloat_operand")
|
||||
(match_operand:VEC_F 2 "vfloat_operand")))]
|
||||
"VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
|
||||
{
|
||||
emit_insn (gen_vector_ge<mode> (operands[0], operands[1], operands[2]));
|
||||
emit_insn (gen_one_cmpl<mode>2 (operands[0], operands[0]));
|
||||
DONE;
|
||||
})
|
||||
|
||||
(define_expand "vector_eq<mode>"
|
||||
[(set (match_operand:VEC_C 0 "vlogical_operand")
|
||||
(eq:VEC_C (match_operand:VEC_C 1 "vlogical_operand")
|
||||
|
@ -575,7 +829,7 @@
|
|||
operands[3] = gen_reg_rtx_and_attrs (operands[0]);
|
||||
})
|
||||
|
||||
(define_insn_and_split "*vector_uneq<mode>"
|
||||
(define_insn_and_split "vector_uneq<mode>"
|
||||
[(set (match_operand:VEC_F 0 "vfloat_operand")
|
||||
(uneq:VEC_F (match_operand:VEC_F 1 "vfloat_operand")
|
||||
(match_operand:VEC_F 2 "vfloat_operand")))]
|
||||
|
@ -596,7 +850,7 @@
|
|||
operands[4] = gen_reg_rtx (<MODE>mode);
|
||||
})
|
||||
|
||||
(define_insn_and_split "*vector_ltgt<mode>"
|
||||
(define_insn_and_split "vector_ltgt<mode>"
|
||||
[(set (match_operand:VEC_F 0 "vfloat_operand")
|
||||
(ltgt:VEC_F (match_operand:VEC_F 1 "vfloat_operand")
|
||||
(match_operand:VEC_F 2 "vfloat_operand")))]
|
||||
|
@ -617,7 +871,7 @@
|
|||
operands[4] = gen_reg_rtx (<MODE>mode);
|
||||
})
|
||||
|
||||
(define_insn_and_split "*vector_ordered<mode>"
|
||||
(define_insn_and_split "vector_ordered<mode>"
|
||||
[(set (match_operand:VEC_F 0 "vfloat_operand")
|
||||
(ordered:VEC_F (match_operand:VEC_F 1 "vfloat_operand")
|
||||
(match_operand:VEC_F 2 "vfloat_operand")))]
|
||||
|
@ -638,7 +892,7 @@
|
|||
operands[4] = gen_reg_rtx (<MODE>mode);
|
||||
})
|
||||
|
||||
(define_insn_and_split "*vector_unordered<mode>"
|
||||
(define_insn_and_split "vector_unordered<mode>"
|
||||
[(set (match_operand:VEC_F 0 "vfloat_operand")
|
||||
(unordered:VEC_F (match_operand:VEC_F 1 "vfloat_operand")
|
||||
(match_operand:VEC_F 2 "vfloat_operand")))]
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
2019-11-08 Kewen Lin <linkw@gcc.gnu.org>
|
||||
|
||||
PR target/92132
|
||||
* gcc.target/powerpc/pr92132-fp-1.c: New test.
|
||||
* gcc.target/powerpc/pr92132-fp-2.c: New test.
|
||||
* gcc.target/powerpc/pr92132-int-1.c: New test.
|
||||
* gcc.target/powerpc/pr92132-int-2.c: New test.
|
||||
|
||||
2019-11-08 Hongtao Liu <hongtao.liu@intel.com>
|
||||
|
||||
* gcc.target/i386/pr92295.c: New test.
|
||||
|
|
297
gcc/testsuite/gcc.target/powerpc/pr92132-fp-1.c
Normal file
297
gcc/testsuite/gcc.target/powerpc/pr92132-fp-1.c
Normal file
|
@ -0,0 +1,297 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target vsx_hw } */
|
||||
/* { dg-options "-O2 -ftree-vectorize -mvsx -fno-vect-cost-model -fdump-tree-vect-details" } */
|
||||
|
||||
/* To test condition reduction vectorization, where comparison operands are of
|
||||
double type and condition true/false values are integer type. Cover all
|
||||
float point comparison codes. */
|
||||
|
||||
#include <math.h>
|
||||
|
||||
extern void
|
||||
abort (void) __attribute__ ((noreturn));
|
||||
|
||||
#define N 27
|
||||
#define FP_TYPE double
|
||||
|
||||
#define LTGT(a, b) (__builtin_islessgreater ((a), (b)))
|
||||
#define UNORD(a, b) (__builtin_isunordered ((a), (b)))
|
||||
#define ORD(a, b) (!__builtin_isunordered ((a), (b)))
|
||||
#define UNEQ(a, b) (!__builtin_islessgreater ((a), (b)))
|
||||
#define UNGT(a, b) (!__builtin_islessequal ((a), (b)))
|
||||
#define UNGE(a, b) (!__builtin_isless ((a), (b)))
|
||||
#define UNLT(a, b) (!__builtin_isgreaterequal ((a), (b)))
|
||||
#define UNLE(a, b) (!__builtin_isgreater ((a), (b)))
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_eq (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] == min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_ne (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] != min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_gt (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] > min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_ge (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] >= min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_lt (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] < min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_le (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] <= min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_ltgt (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (LTGT (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_ord (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (ORD (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_unord (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (UNORD (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_uneq (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (UNEQ (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_ungt (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (UNGT (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_unge (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (UNGE (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_unlt (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (UNLT (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_unle (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (UNLE (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
FP_TYPE a1[N] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4,
|
||||
5, 6, 7, 8, 9, 10, 21, 22, 23, 24, 25, 26, 27};
|
||||
|
||||
FP_TYPE a2[N] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4,
|
||||
5, 6, 7, 8, 9, 10, 21, 22, 23, NAN, 25, 26, 27};
|
||||
|
||||
FP_TYPE a3[N] = {21, 22, 23, 24, 25, 26, 27, 28, 29, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7};
|
||||
|
||||
FP_TYPE a4[N] = {21, 22, 23, 24, 25, 26, 27, 28, 29, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 1, 2, 3, 4, NAN, 6, 7};
|
||||
|
||||
FP_TYPE a5[N] = {21, 22, 23, 24, 25, 26, 27, 28, 29, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 1, 2, 3, 4, NAN, 10, 10};
|
||||
|
||||
ret = test_eq (a1, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_ne (a1, 10);
|
||||
if (ret != 26)
|
||||
abort ();
|
||||
|
||||
ret = test_gt (a3, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_ge (a3, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_lt (a1, 10);
|
||||
if (ret != 18)
|
||||
abort ();
|
||||
|
||||
ret = test_le (a1, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_ltgt (a3, 10);
|
||||
if (ret != 26)
|
||||
abort ();
|
||||
|
||||
ret = test_ltgt (a5, 10);
|
||||
if (ret != 23)
|
||||
abort ();
|
||||
|
||||
ret = test_unord (a5, 10);
|
||||
if (ret != 24)
|
||||
abort ();
|
||||
|
||||
ret = test_ord (a5, 10);
|
||||
if (ret != 26)
|
||||
abort ();
|
||||
|
||||
ret = test_uneq (a1, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_uneq (a4, 10);
|
||||
if (ret != 24)
|
||||
abort ();
|
||||
|
||||
ret = test_ungt (a3, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_ungt (a4, 10);
|
||||
if (ret != 24)
|
||||
abort ();
|
||||
|
||||
ret = test_unge (a3, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_ungt (a4, 10);
|
||||
if (ret != 24)
|
||||
abort ();
|
||||
|
||||
ret = test_unlt (a1, 10);
|
||||
if (ret != 18)
|
||||
abort ();
|
||||
|
||||
ret = test_unlt (a2, 10);
|
||||
if (ret != 23)
|
||||
abort ();
|
||||
|
||||
ret = test_unle (a1, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_unle (a2, 10);
|
||||
if (ret != 23)
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 14 "vect" } } */
|
297
gcc/testsuite/gcc.target/powerpc/pr92132-fp-2.c
Normal file
297
gcc/testsuite/gcc.target/powerpc/pr92132-fp-2.c
Normal file
|
@ -0,0 +1,297 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target vmx_hw } */
|
||||
/* { dg-options "-O2 -ftree-vectorize -maltivec -fno-vect-cost-model -fdump-tree-vect-details" } */
|
||||
|
||||
/* To test condition reduction vectorization, where comparison operands are of
|
||||
float type and condition true/false values are integer type. Cover all
|
||||
float point comparison codes. */
|
||||
|
||||
#include <math.h>
|
||||
|
||||
extern void
|
||||
abort (void) __attribute__ ((noreturn));
|
||||
|
||||
#define N 27
|
||||
#define FP_TYPE float
|
||||
|
||||
#define LTGT(a, b) (__builtin_islessgreater ((a), (b)))
|
||||
#define UNORD(a, b) (__builtin_isunordered ((a), (b)))
|
||||
#define ORD(a, b) (!__builtin_isunordered ((a), (b)))
|
||||
#define UNEQ(a, b) (!__builtin_islessgreater ((a), (b)))
|
||||
#define UNGT(a, b) (!__builtin_islessequal ((a), (b)))
|
||||
#define UNGE(a, b) (!__builtin_isless ((a), (b)))
|
||||
#define UNLT(a, b) (!__builtin_isgreaterequal ((a), (b)))
|
||||
#define UNLE(a, b) (!__builtin_isgreater ((a), (b)))
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_eq (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] == min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_ne (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] != min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_gt (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] > min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_ge (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] >= min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_lt (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] < min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_le (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] <= min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_ltgt (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (LTGT (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_ord (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (ORD (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_unord (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (UNORD (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_uneq (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (UNEQ (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_ungt (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (UNGT (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_unge (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (UNGE (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_unlt (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (UNLT (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_unle (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (UNLE (a[i], min_v))
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
FP_TYPE a1[N] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4,
|
||||
5, 6, 7, 8, 9, 10, 21, 22, 23, 24, 25, 26, 27};
|
||||
|
||||
FP_TYPE a2[N] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4,
|
||||
5, 6, 7, 8, 9, 10, 21, 22, 23, NAN, 25, 26, 27};
|
||||
|
||||
FP_TYPE a3[N] = {21, 22, 23, 24, 25, 26, 27, 28, 29, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7};
|
||||
|
||||
FP_TYPE a4[N] = {21, 22, 23, 24, 25, 26, 27, 28, 29, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 1, 2, 3, 4, NAN, 6, 7};
|
||||
|
||||
FP_TYPE a5[N] = {21, 22, 23, 24, 25, 26, 27, 28, 29, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 1, 2, 3, 4, NAN, 10, 10};
|
||||
|
||||
ret = test_eq (a1, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_ne (a1, 10);
|
||||
if (ret != 26)
|
||||
abort ();
|
||||
|
||||
ret = test_gt (a3, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_ge (a3, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_lt (a1, 10);
|
||||
if (ret != 18)
|
||||
abort ();
|
||||
|
||||
ret = test_le (a1, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_ltgt (a3, 10);
|
||||
if (ret != 26)
|
||||
abort ();
|
||||
|
||||
ret = test_ltgt (a5, 10);
|
||||
if (ret != 23)
|
||||
abort ();
|
||||
|
||||
ret = test_unord (a5, 10);
|
||||
if (ret != 24)
|
||||
abort ();
|
||||
|
||||
ret = test_ord (a5, 10);
|
||||
if (ret != 26)
|
||||
abort ();
|
||||
|
||||
ret = test_uneq (a1, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_uneq (a4, 10);
|
||||
if (ret != 24)
|
||||
abort ();
|
||||
|
||||
ret = test_ungt (a3, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_ungt (a4, 10);
|
||||
if (ret != 24)
|
||||
abort ();
|
||||
|
||||
ret = test_unge (a3, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_ungt (a4, 10);
|
||||
if (ret != 24)
|
||||
abort ();
|
||||
|
||||
ret = test_unlt (a1, 10);
|
||||
if (ret != 18)
|
||||
abort ();
|
||||
|
||||
ret = test_unlt (a2, 10);
|
||||
if (ret != 23)
|
||||
abort ();
|
||||
|
||||
ret = test_unle (a1, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_unle (a2, 10);
|
||||
if (ret != 23)
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 14 "vect" } } */
|
126
gcc/testsuite/gcc.target/powerpc/pr92132-int-1.c
Normal file
126
gcc/testsuite/gcc.target/powerpc/pr92132-int-1.c
Normal file
|
@ -0,0 +1,126 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target p8vector_hw } */
|
||||
/* { dg-options "-O2 -ftree-vectorize -mdejagnu-cpu=power8 -fno-vect-cost-model -fdump-tree-vect-details" } */
|
||||
|
||||
/* To test condition reduction vectorization, where comparison operands are of
|
||||
signed long long type and condition true/false values are integer type. */
|
||||
|
||||
#include <math.h>
|
||||
|
||||
extern void
|
||||
abort (void) __attribute__ ((noreturn));
|
||||
|
||||
#define N 27
|
||||
#define FP_TYPE signed long long
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_eq (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] == min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_ne (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] != min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_gt (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] > min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_ge (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] >= min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_lt (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] < min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_le (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] <= min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
FP_TYPE a1[N] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4,
|
||||
5, 6, 7, 8, 9, 10, 21, 22, 23, 24, 25, 26, 27};
|
||||
|
||||
FP_TYPE a2[N] = {21, 22, 23, 24, 25, 26, 27, 28, 29, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7};
|
||||
|
||||
ret = test_eq (a1, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_ne (a1, 10);
|
||||
if (ret != 26)
|
||||
abort ();
|
||||
|
||||
ret = test_gt (a2, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_ge (a2, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_lt (a1, 10);
|
||||
if (ret != 18)
|
||||
abort ();
|
||||
|
||||
ret = test_le (a1, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 6 "vect" } } */
|
126
gcc/testsuite/gcc.target/powerpc/pr92132-int-2.c
Normal file
126
gcc/testsuite/gcc.target/powerpc/pr92132-int-2.c
Normal file
|
@ -0,0 +1,126 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target p8vector_hw } */
|
||||
/* { dg-options "-O2 -ftree-vectorize -mdejagnu-cpu=power8 -fno-vect-cost-model -fdump-tree-vect-details" } */
|
||||
|
||||
/* To test condition reduction vectorization, where comparison operands are of
|
||||
unsigned long long type and condition true/false values are integer type. */
|
||||
|
||||
#include <math.h>
|
||||
|
||||
extern void
|
||||
abort (void) __attribute__ ((noreturn));
|
||||
|
||||
#define N 27
|
||||
#define FP_TYPE unsigned long long
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_eq (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] == min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_ne (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] != min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_gt (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] > min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_ge (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] >= min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_lt (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] < min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
__attribute__ ((noinline)) int
|
||||
test_le (FP_TYPE *a, FP_TYPE min_v)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
if (a[i] <= min_v)
|
||||
last = i;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
FP_TYPE a1[N] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4,
|
||||
5, 6, 7, 8, 9, 10, 21, 22, 23, 24, 25, 26, 27};
|
||||
|
||||
FP_TYPE a2[N] = {21, 22, 23, 24, 25, 26, 27, 28, 29, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7};
|
||||
|
||||
ret = test_eq (a1, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_ne (a1, 10);
|
||||
if (ret != 26)
|
||||
abort ();
|
||||
|
||||
ret = test_gt (a2, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_ge (a2, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
ret = test_lt (a1, 10);
|
||||
if (ret != 18)
|
||||
abort ();
|
||||
|
||||
ret = test_le (a1, 10);
|
||||
if (ret != 19)
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 6 "vect" } } */
|
Loading…
Add table
Reference in a new issue