|
| 1 | +// RUN: %clangxx -fsycl -Xclang -opaque-pointers -fsycl-device-only -Xclang -emit-llvm -o %t.comp.ll %s |
| 2 | +// RUN: sycl-post-link -ir-output-only -lower-esimd -S %t.comp.ll -o %t.out.ll |
| 3 | +// RUN: FileCheck --input-file=%t.out.ll %s |
| 4 | + |
| 5 | +// Checks that ESIMDOptimizeVecArgCallConv does the right job as |
| 6 | +// a part of sycl-post-link. |
| 7 | + |
| 8 | +#include <sycl/ext/intel/esimd.hpp> |
| 9 | + |
| 10 | +using namespace sycl::ext::intel::esimd; |
| 11 | + |
| 12 | +// clang-format off |
| 13 | + |
| 14 | +//------------------------ |
| 15 | +// Test1: Optimized parameter interleaves non - optimizeable ones. |
| 16 | + |
| 17 | +__attribute__((noinline)) |
| 18 | +SYCL_EXTERNAL simd<int, 8> callee__sret__x_param_x(int i, simd<int, 8> x, int j) SYCL_ESIMD_FUNCTION { |
| 19 | +// CHECK: define dso_local spir_func <8 x i32> @_Z23callee__sret__x_param_x{{.*}}(i32 noundef %{{.*}}, <8 x i32> %{{.*}}, i32 noundef %{{.*}}) |
| 20 | + return x + (i + j); |
| 21 | +} |
| 22 | + |
| 23 | +__attribute__((noinline)) |
| 24 | +SYCL_EXTERNAL simd<int, 8> test__sret__x_param_x(simd<int, 8> x) SYCL_ESIMD_FUNCTION { |
| 25 | +// CHECK: define dso_local spir_func <8 x i32> @_Z21test__sret__x_param_x{{.*}}(<8 x i32> %{{.*}}) |
| 26 | + return callee__sret__x_param_x(2, x, 1); |
| 27 | +// CHECK: %{{.*}} = call spir_func <8 x i32> @_Z23callee__sret__x_param_x{{.*}}(i32 2, <8 x i32> %{{.*}}, i32 1) |
| 28 | +} |
| 29 | + |
| 30 | +//------------------------ |
| 31 | +// Test2: "2-level fall through" |
| 32 | + |
| 33 | +__attribute__((noinline)) |
| 34 | +SYCL_EXTERNAL simd<double, 32> callee__all_fall_through0(simd<double, 32> x) SYCL_ESIMD_FUNCTION { |
| 35 | +// CHECK: define dso_local spir_func <32 x double> @_Z25callee__all_fall_through0{{.*}}(<32 x double> %{{.*}}) |
| 36 | + return x; |
| 37 | +} |
| 38 | + |
| 39 | +__attribute__((noinline)) |
| 40 | +SYCL_EXTERNAL simd<double, 32> callee__all_fall_through1(simd<double, 32> x) SYCL_ESIMD_FUNCTION { |
| 41 | +// CHECK: define dso_local spir_func <32 x double> @_Z25callee__all_fall_through1{{.*}}(<32 x double> %{{.*}}) |
| 42 | + return callee__all_fall_through0(x); |
| 43 | +// CHECK: %{{.*}} = call spir_func <32 x double> @_Z25callee__all_fall_through0{{.*}}(<32 x double> %{{.*}}) |
| 44 | +} |
| 45 | + |
| 46 | +__attribute__((noinline)) |
| 47 | +SYCL_EXTERNAL simd<double, 32> test__all_fall_through(simd<double, 32> x) SYCL_ESIMD_FUNCTION { |
| 48 | +// CHECK: define dso_local spir_func <32 x double> @_Z22test__all_fall_through{{.*}}(<32 x double> %{{.*}}) |
| 49 | + return callee__all_fall_through1(x); |
| 50 | +// CHECK: %{{.*}} = call spir_func <32 x double> @_Z25callee__all_fall_through1{{.*}}(<32 x double> %{{.*}}) |
| 51 | +} |
| 52 | + |
| 53 | +//------------------------ |
| 54 | +// Test3. First argument is passed by reference and updated in the callee, |
| 55 | +// must not be optimized. |
| 56 | + |
| 57 | +__attribute__((noinline)) |
| 58 | +SYCL_EXTERNAL void callee_void__noopt_opt(simd<int, 8>& x, simd<int, 8> y) SYCL_ESIMD_FUNCTION { |
| 59 | +// CHECK: define dso_local spir_func void @_Z22callee_void__noopt_opt{{.*}}(ptr {{.*}} %{{.*}}, <8 x i32> %{{.*}}) |
| 60 | + x = x + y; |
| 61 | +} |
| 62 | + |
| 63 | +__attribute__((noinline)) |
| 64 | +SYCL_EXTERNAL simd<int, 8> test__sret__noopt_opt(simd<int, 8> x) SYCL_ESIMD_FUNCTION { |
| 65 | +// CHECK: define dso_local spir_func <8 x i32> @_Z21test__sret__noopt_opt{{.*}}(ptr noundef %{{.*}}) |
| 66 | + callee_void__noopt_opt(x, x); |
| 67 | +// CHECK: call spir_func void @_Z22callee_void__noopt_opt{{.*}}(ptr addrspace(4) %{{.*}}, <8 x i32> %{{.*}}) |
| 68 | + return x; |
| 69 | +} |
| 70 | + |
| 71 | +//------------------------ |
0 commit comments