OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [vect/] [vect-reduc-dot-u16.c] - Blame information for rev 867

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* { dg-require-effective-target vect_int } */
2
 
3
#include <stdarg.h>
4
#include "tree-vect.h"
5
 
6
#define N 64
7
 
8
#define DOT1 43680
9
#define DOT2 43680
10
 
11
unsigned short X[N] __attribute__ ((__aligned__(16)));
12
unsigned short Y[N] __attribute__ ((__aligned__(16)));
13
 
14
/* short->short->int dot product.
15
   Not detected as a dot-product pattern.
16
   Not vectorized due to presence of type-conversions. */
17
unsigned int
18
foo1(int len) {
19
  int i;
20
  unsigned int result = 0;
21
  unsigned short prod;
22
 
23
  for (i=0; i<len; i++) {
24
    prod = X[i] * Y[i];
25
    result += prod;
26
  }
27
  return result;
28
}
29
 
30
/* short->int->int dot product.
31
   Currently not detected as a dot-product pattern: the multiplication
32
   promotes the ushorts to int, and then the product is promoted to unsigned
33
   int for the addition.  Which results in an int->unsigned int cast, which
34
   since no bits are modified in the cast should be trivially vectorizable.  */
35
unsigned int
36
foo2(int len) {
37
  int i;
38
  unsigned int result = 0;
39
 
40
  for (i=0; i<len; i++) {
41
    result += (X[i] * Y[i]);
42
  }
43
  return result;
44
}
45
 
46
 
47
int main (void)
48
{
49
  unsigned int dot1, dot2;
50
  int i;
51
 
52
  check_vect ();
53
 
54
  for (i=0; i<N; i++) {
55
    X[i] = i;
56
    Y[i] = 64-i;
57
  }
58
 
59
  dot1 = foo1 (N);
60
  if (dot1 != DOT1)
61
    abort ();
62
 
63
  dot2 = foo2 (N);
64
  if (dot2 != DOT2)
65
    abort ();
66
 
67
  return 0;
68
}
69
 
70
/* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" { xfail *-*-* } } } */
71
 
72
/* Once the dot-product pattern is detected in the second loop, we expect
73
   that loop to be vectorized on vect_udot_hi targets (targets that support
74
   dot-product of unsigned shorts).  */
75
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
76
 
77
/* { dg-final { cleanup-tree-dump "vect" } } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.