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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [vect/] [vect-reduc-dot-u16b.c] - Blame information for rev 689

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 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 DOT2 43680
9
 
10
unsigned short X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
11
unsigned short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
12
 
13
/* short->int->int dot product.
14
   Currently not detected as a dot-product pattern: the multiplication
15
   promotes the ushorts to int, and then the product is promoted to unsigned
16
   int for the addition.  Which results in an int->unsigned int cast, which
17
   since no bits are modified in the cast should be trivially vectorizable.  */
18
__attribute__ ((noinline)) unsigned int
19
foo2(int len) {
20
  int i;
21
  unsigned int result = 0;
22
 
23
  for (i=0; i<len; i++) {
24
    result += (X[i] * Y[i]);
25
  }
26
  return result;
27
}
28
 
29
 
30
int main (void)
31
{
32
  unsigned int  dot2;
33
  int i;
34
 
35
  check_vect ();
36
 
37
  for (i=0; i<N; i++) {
38
    X[i] = i;
39
    Y[i] = 64-i;
40
    __asm__ volatile ("");
41
  }
42
 
43
  dot2 = foo2 (N);
44
  if (dot2 != DOT2)
45
    abort ();
46
 
47
  return 0;
48
}
49
 
50
/* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" { xfail *-*-* } } } */
51
 
52
/* Once the dot-product pattern is detected, we expect
53
   that loop to be vectorized on vect_udot_hi targets (targets that support
54
   dot-product of unsigned shorts) and targets that support widening multiplication.  */
55
/* The induction loop in main is vectorized.  */
56
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail *-*-* } } } */
57
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_pack_trunc } } } */
58
 
59
/* { 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.