+2006-02-16 Victor Kaplansky <victork@il.ibm.com>
+
+ PR tree-opt/25918
+ * lib/target-supports.exp
+ (check_effective_target_vect_short_mult): New.
+ (check_effective_target_vect_char_mult): New.
+ (check_effective_target_vect_widen_sum_qi_to_si): New.
+ (check_effective_target_vect_widen_sum_qi_to_hi): New.
+ (check_effective_target_vect_widen_sum_hi_to_si): New.
+ * gcc.dg/vect/vect-reduc-dot-s16.c: Remove, split into
+ vect-reduc-dot-s16a.c and vect-reduc-dot-s16b.c
+ * vect-reduc-dot-s16a.c: New, split from vect-reduc-dot-s16.c.
+ * vect-reduc-dot-s16b.c: New, split from vect-reduc-dot-s16.c.
+ * gcc.dg/vect/vect-reduc-pattern-2.c: Remove, split into
+ vect-reduc-pattern-2a.c, vect-reduc-pattern-2b.c and
+ vect-reduc-pattern-2c.c
+ * gcc.dg/vect/vect-reduc-pattern-1.c: Remove, split into
+ vect-reduc-pattern-1a.c, vect-reduc-pattern-1b.c and
+ vect-reduc-pattern-1c.c
+
2005-02-16 Paul Thomas <pault@gcc.gnu.org>
PR fortran/24557
+++ /dev/null
-/* { dg-require-effective-target vect_int } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 64
-
-#define DOT1 43680
-#define DOT2 43680
-
-signed short X[N] __attribute__ ((__aligned__(16)));
-signed short Y[N] __attribute__ ((__aligned__(16)));
-
-/* short->short->int dot product.
- Not detected as a dot-product pattern.
- Currently fails to be vectorized due to presence of type conversions. */
-int
-foo1(int len) {
- int i;
- int result = 0;
- short prod;
-
- for (i=0; i<len; i++) {
- prod = X[i] * Y[i];
- result += prod;
- }
- return result;
-}
-
-/* short->int->int dot product.
- Detected as a dot-product pattern.
- Vectorized on targets that support dot-product for signed shorts. */
-int
-foo2(int len) {
- int i;
- int result = 0;
-
- for (i=0; i<len; i++) {
- result += (X[i] * Y[i]);
- }
- return result;
-}
-
-
-int main (void)
-{
- int i, dot1, dot2;
-
- check_vect ();
-
- for (i=0; i<N; i++) {
- X[i] = i;
- Y[i] = 64-i;
- }
-
- dot1 = foo1 (N);
- if (dot1 != DOT1)
- abort ();
-
- dot2 = foo2 (N);
- if (dot2 != DOT2)
- abort ();
-
- return 0;
-}
-
-/* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" } } */
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_sdot_hi } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
-
--- /dev/null
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 64
+#define DOT 43680
+
+signed short X[N] __attribute__ ((__aligned__(16)));
+signed short Y[N] __attribute__ ((__aligned__(16)));
+
+/* short->int->int dot product.
+ Detected as a dot-product pattern.
+ Vectorized on targets that support dot-product for signed shorts. */
+
+int
+foo (int len)
+{
+ int i;
+ int result = 0;
+
+ for (i = 0; i < len; i++)
+ {
+ result += (X[i] * Y[i]);
+ }
+ return result;
+}
+
+
+int
+main (void)
+{
+ int i;
+ int dot;
+
+ check_vect ();
+
+ for (i = 0; i < N; i++)
+ {
+ X[i] = i;
+ Y[i] = N - i;
+ }
+
+ dot = foo (N);
+ if (dot != DOT)
+ abort ();
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_sdot_hi } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
--- /dev/null
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 64
+
+#define DOT 43680
+
+signed short X[N] __attribute__ ((__aligned__(16)));
+signed short Y[N] __attribute__ ((__aligned__(16)));
+
+/* short->short->int dot product. Should be vectorized on architectures
+ supporting vectorized multiplication of two short args with short result,
+ e.g "mulv4hi3" and widenning sum */
+int
+foo (int len)
+{
+ int i;
+ int result = 0;
+ short prod;
+
+ for (i = 0; i < len; i++)
+ {
+ prod = X[i] * Y[i];
+ result += prod;
+ }
+ return result;
+}
+
+int
+main (void)
+{
+ int i, dot;
+
+ check_vect ();
+
+ for (i = 0; i < N; i++)
+ {
+ X[i] = i;
+ Y[i] = 64 - i;
+ }
+
+ dot = foo (N);
+ if (dot != DOT)
+ abort ();
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_short_mult && vect_widen_sum_hi_to_si } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_short_mult } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_hi_to_si } } } } */
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
+++ /dev/null
-/* { dg-require-effective-target vect_int } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 16
-#define SH_SUM 210
-#define CH_SUM 120
-
-int main1 ()
-{
- int i;
- unsigned short udata_sh[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28};
- unsigned char udata_ch[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
- unsigned int intsum = 0;
- unsigned short shortsum = 0;
-
- /* widenning sum: sum shorts into int. */
- for (i = 0; i < N; i++){
- intsum += udata_sh[i];
- }
-
- /* check results: */
- if (intsum != SH_SUM)
- abort ();
-
- /* widenning sum: sum chars into int. */
- intsum = 0;
- for (i = 0; i < N; i++){
- intsum += udata_ch[i];
- }
-
- /* check results: */
- if (intsum != CH_SUM)
- abort ();
-
- /* widenning sum: sum chars into short.
- pattern detected, but not vectorized yet. */
- for (i = 0; i < N; i++){
- shortsum += udata_ch[i];
- }
-
- /* check results: */
- if (shortsum != CH_SUM)
- abort ();
-
- return 0;
-}
-
-int main (void)
-{
- check_vect ();
-
- return main1 ();
-}
-
-/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected" 3 "vect" } } */
-/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target vect_widen_sum } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
--- /dev/null
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+unsigned short udata_sh[N] =
+ { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 };
+#define SUM 210
+
+int
+foo ()
+{
+ int i;
+ unsigned int intsum = 0;
+
+ /* widenning sum: sum shorts into int. */
+ for (i = 0; i < N; i++)
+ {
+ intsum += udata_sh[i];
+ }
+
+ /* check results: */
+ if (intsum != SUM)
+ abort ();
+
+ return 0;
+}
+
+int
+main (void)
+{
+ check_vect ();
+ return foo ();
+}
+
+/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_sum_hi_to_si } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_hi_to_si } } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
--- /dev/null
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+unsigned char udata_ch[N] =
+ { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 };
+#define SUM 210
+
+int
+foo ()
+{
+ int i;
+ unsigned int intsum = 0;
+
+ /* widenning sum: sum chars into int. */
+ for (i = 0; i < N; i++)
+ {
+ intsum += udata_ch[i];
+ }
+
+ /* check results: */
+ if (intsum != SUM)
+ abort ();
+
+ return 0;
+}
+
+int
+main (void)
+{
+ check_vect ();
+ return foo ();
+}
+
+/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_sum_qi_to_si } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_qi_to_si } } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
--- /dev/null
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+unsigned char udata_ch[N] =
+ { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 };
+#define SUM 210
+
+int
+foo ()
+{
+ int i;
+ unsigned short shortsum = 0;
+
+ /* widenning sum: sum chars into short. */
+ for (i = 0; i < N; i++)
+ {
+ shortsum += udata_ch[i];
+ }
+
+ /* check results: */
+ if (shortsum != SUM)
+ abort ();
+
+ return 0;
+}
+
+int
+main (void)
+{
+ check_vect ();
+ return foo ();
+}
+
+/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_sum_qi_to_hi } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_qi_to_hi } } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+++ /dev/null
-/* { dg-require-effective-target vect_int } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 16
-#define SH_SUM 210
-#define CH_SUM 120
-
-int main1 ()
-{
- int i;
- signed short data_sh[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28};
- signed char data_ch[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
- signed int intsum = 0;
- signed short shortsum = 0;
-
- /* widenning sum: sum shorts into int. */
- for (i = 0; i < N; i++){
- intsum += data_sh[i];
- }
-
- /* check results: */
- if (intsum != SH_SUM)
- abort ();
-
- /* widenning sum: sum chars into int. */
- intsum = 0;
- for (i = 0; i < N; i++){
- intsum += data_ch[i];
- }
-
- /* check results: */
- if (intsum != CH_SUM)
- abort ();
-
- /* widenning sum: sum chars into short.
- The widening-summation pattern is currently not detected because of this
- patch:
-
- 2005-12-26 Kazu Hirata <kazu@codesourcery.com>
-
- PR tree-optimization/25125
- */
- for (i = 0; i < N; i++){
- shortsum += data_ch[i];
- }
-
- /* check results: */
- if (shortsum != CH_SUM)
- abort ();
-
- return 0;
-}
-
-int main (void)
-{
- check_vect ();
-
- return main1 ();
-}
-
-/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected" 3 "vect" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected" 2 "vect" } } */
-/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target vect_widen_sum } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
--- /dev/null
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+signed short data_sh[N] =
+ { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 };
+#define SUM 210
+
+int
+foo ()
+{
+ int i;
+ signed int intsum = 0;
+
+ /* widenning sum: sum shorts into int. */
+ for (i = 0; i < N; i++)
+ {
+ intsum += data_sh[i];
+ }
+
+ /* check results: */
+ if (intsum != SUM)
+ abort ();
+
+ return 0;
+}
+
+int
+main (void)
+{
+ check_vect ();
+ return foo ();
+}
+
+/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_sum_hi_to_si } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_hi_to_si } } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
--- /dev/null
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+signed char data_ch[N] =
+ { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 };
+#define SUM 210
+
+int
+foo ()
+{
+ int i;
+ signed int intsum = 0;
+
+ /* widenning sum: sum chars into int. */
+ for (i = 0; i < N; i++)
+ {
+ intsum += data_ch[i];
+ }
+
+ /* check results: */
+ if (intsum != SUM)
+ abort ();
+
+ return 0;
+}
+
+int
+main (void)
+{
+ check_vect ();
+ return foo ();
+}
+
+/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_sum_qi_to_si } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_qi_to_si } } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
--- /dev/null
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+signed char data_ch[N] =
+ { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 };
+#define SUM 210
+
+int
+foo ()
+{
+ int i;
+ signed short shortsum = 0;
+
+ /* widenning sum: sum chars into short.
+ The widening-summation pattern is currently not detected because of this
+ patch:
+
+ 2005-12-26 Kazu Hirata <kazu@codesourcery.com>
+
+ PR tree-optimization/25125
+ */
+
+ for (i = 0; i < N; i++)
+ {
+ shortsum += data_ch[i];
+ }
+
+ /* check results: */
+ if (shortsum != SUM)
+ abort ();
+
+ return 0;
+}
+
+int
+main (void)
+{
+ check_vect ();
+ return foo ();
+}
+
+/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_qi_to_hi } } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+++ /dev/null
-/* { dg-require-effective-target vect_int } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 16
-#define SH_SUM 210
-#define CH_SUM 120
-
-int main1 ()
-{
- int i;
- signed short data_sh[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28};
- signed char data_ch[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
- signed int intsum = 0;
- signed short shortsum = 0;
-
- /* widenning sum: sum shorts into int. */
- for (i = 0; i < N; i++){
- intsum += data_sh[i];
- }
-
- /* check results: */
- if (intsum != SH_SUM)
- abort ();
-
- /* widenning sum: sum chars into int. */
- intsum = 0;
- for (i = 0; i < N; i++){
- intsum += data_ch[i];
- }
-
- /* check results: */
- if (intsum != CH_SUM)
- abort ();
-
- /* widenning sum: sum chars into short. */
- for (i = 0; i < N; i++){
- shortsum += data_ch[i];
- }
-
- /* check results: */
- if (shortsum != CH_SUM)
- abort ();
-
- return 0;
-}
-
-int main (void)
-{
- check_vect ();
-
- return main1 ();
-}
-
-/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected" 3 "vect" } } */
-/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target vect_widen_sum } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
--- /dev/null
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+signed char data_ch[N] =
+ { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28 };
+#define SUM 210
+
+int
+foo ()
+{
+ int i;
+ signed short shortsum = 0;
+
+ /* widenning sum: sum chars into short. */
+
+ for (i = 0; i < N; i++)
+ {
+ shortsum += data_ch[i];
+ }
+
+ /* check results: */
+ if (shortsum != SUM)
+ abort ();
+
+ return 0;
+}
+
+int
+main (void)
+{
+ check_vect ();
+ return foo ();
+}
+
+/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: detected" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_widen_sum_qi_to_hi } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" { target { ! vect_widen_sum_qi_to_hi } } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
return $et_vect_no_bitwise_saved
}
+# Return 1 if the target plus current options supports a vector
+# widening summation of *short* args into *int* result, 0 otherwise.
+#
+# This won't change for different subtargets so cache the result.
+
+proc check_effective_target_vect_widen_sum_hi_to_si { } {
+ global et_vect_widen_sum_hi_to_si
+
+ if [info exists et_vect_widen_sum_hi_to_si_saved] {
+ verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
+ } else {
+ set et_vect_widen_sum_hi_to_si_saved 0
+ if { [istarget powerpc*-*-*]
+ || [istarget ia64-*-*] } {
+ set et_vect_widen_sum_hi_to_si_saved 1
+ }
+ }
+ verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
+ return $et_vect_widen_sum_hi_to_si_saved
+}
+
+# Return 1 if the target plus current options supports a vector
+# widening summation of *char* args into *short* result, 0 otherwise.
+#
+# This won't change for different subtargets so cache the result.
+
+proc check_effective_target_vect_widen_sum_qi_to_hi { } {
+ global et_vect_widen_sum_qi_to_hi
+
+ if [info exists et_vect_widen_sum_qi_to_hi_saved] {
+ verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
+ } else {
+ set et_vect_widen_sum_qi_to_hi_saved 0
+ if { [istarget ia64-*-*] } {
+ set et_vect_widen_sum_qi_to_hi_saved 1
+ }
+ }
+ verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
+ return $et_vect_widen_sum_qi_to_hi_saved
+}
+
+# Return 1 if the target plus current options supports a vector
+# widening summation of *char* args into *int* result, 0 otherwise.
+#
+# This won't change for different subtargets so cache the result.
+
+proc check_effective_target_vect_widen_sum_qi_to_si { } {
+ global et_vect_widen_sum_qi_to_si
+
+ if [info exists et_vect_widen_sum_qi_to_si_saved] {
+ verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
+ } else {
+ set et_vect_widen_sum_qi_to_si_saved 0
+ if { [istarget powerpc*-*-*] } {
+ set et_vect_widen_sum_qi_to_si_saved 1
+ }
+ }
+ verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
+ return $et_vect_widen_sum_qi_to_si_saved
+}
+
# Return 1 if the target plus current options supports a vector
# widening summation, 0 otherwise.
#
return $et_vect_cond_saved
}
+# Return 1 if the target supports vector char multiplication, 0 otherwise.
+
+proc check_effective_target_vect_char_mult { } {
+ global et_vect_char_mult_saved
+
+ if [info exists et_vect_char_mult_saved] {
+ verbose "check_effective_target_vect_char_mult: using cached result" 2
+ } else {
+ set et_vect_char_mult_saved 0
+ if { [istarget ia64-*-*]
+ || [istarget i?86-*-*]
+ || [istarget x86_64-*-*] } {
+ set et_vect_char_mult_saved 1
+ }
+ }
+
+ verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
+ return $et_vect_char_mult_saved
+}
+
+# Return 1 if the target supports vector short multiplication, 0 otherwise.
+
+proc check_effective_target_vect_short_mult { } {
+ global et_vect_short_mult_saved
+
+ if [info exists et_vect_short_mult_saved] {
+ verbose "check_effective_target_vect_short_mult: using cached result" 2
+ } else {
+ set et_vect_short_mult_saved 0
+ if { [istarget ia64-*-*]
+ || [istarget i?86-*-*]
+ || [istarget x86_64-*-*] } {
+ set et_vect_short_mult_saved 1
+ }
+ }
+
+ verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
+ return $et_vect_short_mult_saved
+}
+
# Return 1 if the target supports vector int multiplication, 0 otherwise.
proc check_effective_target_vect_int_mult { } {