File: 708.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 (40 lines) | stat: -rw-r--r-- 790 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// This test checks that generated code does not try to divide by zero.

// RUN: %{ispc} --pic --target=host %s -o %t.o
// RUN: %{cc} %t.o -o %t.c.bin
// RUN: %t.c.bin | FileCheck %s

// REQUIRES: !MACOS_HOST

// CHECK-NOT: Floating point exception

export void test(uniform int nb)
{
    foreach(i = 0 ... nb)
    {
        // foreach (j = nb+1 ... 1)
        float j = nb + 1 - i;
        float k;
        if (j > 0)
            k = nb / j;
        else
            k = -1;
        print("%\n", k);
    }
    foreach(i = 0 ... nb)
    {
        // foreach (j = nb+1 ... 1)
        int j = nb + 1 - i;
        int k;
        if (j > 0)
            k = nb / j;
        else
            k = -1;
        print("%\n", k);
    }
}

extern "C" uniform int main() {
    test(12);
    return 0;
}