File: 3229.ispc

package info (click to toggle)
ispc 1.28.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 97,620 kB
  • sloc: cpp: 77,067; python: 8,303; yacc: 3,337; lex: 1,126; ansic: 631; sh: 475; makefile: 17
file content (25 lines) | stat: -rw-r--r-- 857 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Check argument type deduction for template functions with short vector types

// RUN: %{ispc} -O2 --target=avx512icl-x4 --nowrap --nostdlib --emit-llvm-text %s -o - | FileCheck %s

// REQUIRES: X86_ENABLED

// CHECK-NOT: Error: Unable to find any matching overload for call to function

uniform int foo(uniform int a, uniform int b) { return a + b; }
varying int foo(varying int a, varying int b) { return a + b; }

template <typename T, uint N> uniform T<N> foo(uniform T<N> a, uniform T<N> b) {
    uniform T<N> result;
    foreach (i = 0 ... N) {
        result[i] = foo(a[i], b[i]);
    }
    return result;
}

// CHECK-LABEL: @bar___{{.*}}(<4 x i32> %a, <4 x i32> %b, {{.*}}
// CHECK-DAG:   [[RET:%.*]] = add nsw <4 x i32> %b, %a
// CHECK-DAG:   ret <4 x i32> [[RET]]
uniform int<4> bar(uniform int<4> a, uniform int<4> b) {
    return foo(a, b);
}