|
| 1 | +//==-------------- vec_arg_call_conv_ext.cpp - DPC++ ESIMD feature test ---==// |
| 2 | +// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | +// Intel GPU is not really required, but the test does not make sense for |
| 9 | +// others. |
| 10 | +// REQUIRES: gpu |
| 11 | +// UNSUPPORTED: cuda || hip |
| 12 | +// RUN: %clangxx -fsycl -Xclang -opaque-pointers -fsycl-device-only -Xclang -emit-llvm -o %t.comp.ll %s |
| 13 | +// RUN: sycl-post-link -ir-output-only -lower-esimd -S %t.comp.ll -o %t.out.ll |
| 14 | +// RUN: FileCheck --input-file=%t.out.ll %s |
| 15 | + |
| 16 | +// Checks that ESIMDOptimizeVecArgCallConv does the right job as |
| 17 | +// a part of sycl-post-link. |
| 18 | + |
| 19 | +#include <sycl/ext/intel/esimd.hpp> |
| 20 | + |
| 21 | +using namespace sycl::ext::intel::esimd; |
| 22 | + |
| 23 | +// clang-format off |
| 24 | + |
| 25 | +//------------------------ |
| 26 | +// Test1: Optimized parameter interleaves non - optimizeable ones. |
| 27 | + |
| 28 | +__attribute__((noinline)) |
| 29 | +SYCL_EXTERNAL simd<int, 8> callee__sret__x_param_x(int i, simd<int, 8> x, int j) SYCL_ESIMD_FUNCTION { |
| 30 | +// CHECK: define dso_local spir_func <8 x i32> @_Z23callee__sret__x_param_x{{.*}}(i32 noundef %{{.*}}, <8 x i32> %{{.*}}, i32 noundef %{{.*}}) |
| 31 | + return x + (i + j); |
| 32 | +} |
| 33 | + |
| 34 | +__attribute__((noinline)) |
| 35 | +SYCL_EXTERNAL simd<int, 8> test__sret__x_param_x(simd<int, 8> x) SYCL_ESIMD_FUNCTION { |
| 36 | +// CHECK: define dso_local spir_func <8 x i32> @_Z21test__sret__x_param_x{{.*}}(<8 x i32> %{{.*}}) |
| 37 | + return callee__sret__x_param_x(2, x, 1); |
| 38 | +// CHECK: %{{.*}} = call spir_func <8 x i32> @_Z23callee__sret__x_param_x{{.*}}(i32 2, <8 x i32> %{{.*}}, i32 1) |
| 39 | +} |
| 40 | + |
| 41 | +//------------------------ |
| 42 | +// Test2: "2-level fall through" |
| 43 | + |
| 44 | +__attribute__((noinline)) |
| 45 | +SYCL_EXTERNAL simd<double, 32> callee__all_fall_through0(simd<double, 32> x) SYCL_ESIMD_FUNCTION { |
| 46 | +// CHECK: define dso_local spir_func <32 x double> @_Z25callee__all_fall_through0{{.*}}(<32 x double> %{{.*}}) |
| 47 | + return x; |
| 48 | +} |
| 49 | + |
| 50 | +__attribute__((noinline)) |
| 51 | +SYCL_EXTERNAL simd<double, 32> callee__all_fall_through1(simd<double, 32> x) SYCL_ESIMD_FUNCTION { |
| 52 | +// CHECK: define dso_local spir_func <32 x double> @_Z25callee__all_fall_through1{{.*}}(<32 x double> %{{.*}}) |
| 53 | + return callee__all_fall_through0(x); |
| 54 | +// CHECK: %{{.*}} = call spir_func <32 x double> @_Z25callee__all_fall_through0{{.*}}(<32 x double> %{{.*}}) |
| 55 | +} |
| 56 | + |
| 57 | +__attribute__((noinline)) |
| 58 | +SYCL_EXTERNAL simd<double, 32> test__all_fall_through(simd<double, 32> x) SYCL_ESIMD_FUNCTION { |
| 59 | +// CHECK: define dso_local spir_func <32 x double> @_Z22test__all_fall_through{{.*}}(<32 x double> %{{.*}}) |
| 60 | + return callee__all_fall_through1(x); |
| 61 | +// CHECK: %{{.*}} = call spir_func <32 x double> @_Z25callee__all_fall_through1{{.*}}(<32 x double> %{{.*}}) |
| 62 | +} |
| 63 | + |
| 64 | +//------------------------ |
| 65 | +// Test3. First argument is passed by reference and updated in the callee, |
| 66 | +// must not be optimized. |
| 67 | + |
| 68 | +__attribute__((noinline)) |
| 69 | +SYCL_EXTERNAL void callee_void__noopt_opt(simd<int, 8>& x, simd<int, 8> y) SYCL_ESIMD_FUNCTION { |
| 70 | +// CHECK: define dso_local spir_func void @_Z22callee_void__noopt_opt{{.*}}(ptr {{.*}} %{{.*}}, <8 x i32> %{{.*}}) |
| 71 | + x = x + y; |
| 72 | +} |
| 73 | + |
| 74 | +__attribute__((noinline)) |
| 75 | +SYCL_EXTERNAL simd<int, 8> test__sret__noopt_opt(simd<int, 8> x) SYCL_ESIMD_FUNCTION { |
| 76 | +// CHECK: define dso_local spir_func <8 x i32> @_Z21test__sret__noopt_opt{{.*}}(ptr noundef %{{.*}}) |
| 77 | + callee_void__noopt_opt(x, x); |
| 78 | +// CHECK: call spir_func void @_Z22callee_void__noopt_opt{{.*}}(ptr addrspace(4) %{{.*}}, <8 x i32> %{{.*}}) |
| 79 | + return x; |
| 80 | +} |
| 81 | + |
| 82 | +//------------------------ |
| 83 | + |
| 84 | +// Dummy main to satisfy linker. |
| 85 | +int main() { |
| 86 | + return 0; |
| 87 | +} |
0 commit comments