Skip to content

Commit cffc4af

Browse files
authored
Merge branch 'sycl' into gmlueck/mv-deprecated
2 parents 920b237 + 8934dde commit cffc4af

File tree

28 files changed

+743
-1199
lines changed

28 files changed

+743
-1199
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
13841384
// configure the pipeline.
13851385
OptimizationLevel Level = mapToLevel(CodeGenOpts);
13861386

1387+
if (LangOpts.SYCLIsDevice)
1388+
PB.registerPipelineStartEPCallback(
1389+
[](ModulePassManager &MPM, OptimizationLevel Level) {
1390+
MPM.addPass(ESIMDVerifierPass());
1391+
});
1392+
13871393
bool IsThinLTO = CodeGenOpts.PrepareForThinLTO;
13881394
bool IsLTO = CodeGenOpts.PrepareForLTO;
13891395

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -flegacy-pass-manager -mllvm -sycl-opt %s -emit-llvm -o - | FileCheck %s
2+
// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -fno-legacy-pass-manager -mllvm -sycl-opt %s -emit-llvm -o - | FileCheck %s
3+
//
4+
// This test checks that foo (which is @_Z3foov) is called twice after O3 optimizations.
5+
//
6+
// Usually clang with SimplifyCFG pass optimizes constructs like:
7+
// if (i % 2 == 0)
8+
// func();
9+
// else
10+
// func();
11+
//
12+
// into one simple func() invocation.
13+
// This behaviour might be wrong in cases when func's behaviour depends on
14+
// a place where it is written.
15+
// There is a relevant discussion about introducing
16+
// a reliable tool for such cases: https://reviews.llvm.org/D85603
17+
18+
// CHECK: tail call spir_func void @_Z3foov()
19+
// CHECK: tail call spir_func void @_Z3foov()
20+
21+
SYCL_EXTERNAL void foo();
22+
23+
SYCL_EXTERNAL void bar(int i) {
24+
if (i % 2 == 0) {
25+
foo();
26+
} else {
27+
foo();
28+
}
29+
}

libclc/amdgcn-amdhsa/libspirv/SOURCES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,19 @@ math/fmin.cl
3131
math/fmod.cl
3232
math/frexp.cl
3333
math/hypot.cl
34+
math/ilogb.cl
3435
math/ldexp.cl
3536
math/lgamma.cl
3637
math/log.cl
38+
math/log2.cl
3739
math/log10.cl
3840
math/log1p.cl
3941
math/logb.cl
4042
math/mangle_common.h
4143
math/modf.cl
4244
math/nextafter.cl
4345
math/pow.cl
46+
math/remainder.cl
4447
math/round.cl
4548
math/rsqrt.cl
4649
math/sin.cl
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//===----------------------------------------------------------------------===//
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+
9+
#include <clcmacro.h>
10+
#include <spirv/spirv.h>
11+
12+
int __ocml_ilogb_f64(double);
13+
int __ocml_ilogb_f32(float);
14+
15+
_CLC_DEFINE_UNARY_BUILTIN(int, __spirv_ocl_ilogb, __ocml_ilogb_f32, float)
16+
17+
#ifdef cl_khr_fp64
18+
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
19+
20+
_CLC_DEFINE_UNARY_BUILTIN(int, __spirv_ocl_ilogb, __ocml_ilogb_f64, double)
21+
#endif
22+
23+
#ifdef cl_khr_fp16
24+
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
25+
26+
_CLC_OVERLOAD _CLC_DEF int __spirv_ocl_ilogb(half x) {
27+
float t = x;
28+
return __spirv_ocl_ilogb(t);
29+
}
30+
31+
_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, int, __spirv_ocl_ilogb, half);
32+
#endif
33+
34+
#undef __CLC_BUILTIN
35+
#undef __CLC_BUILTIN_F
36+
#undef __CLC_FUNCTION
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===----------------------------------------------------------------------===//
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+
9+
#include <clcmacro.h>
10+
#include <spirv/spirv.h>
11+
12+
double __ocml_log2_f64(double);
13+
float __ocml_log2_f32(float);
14+
15+
#define __CLC_FUNCTION __spirv_ocl_log2
16+
#define __CLC_BUILTIN __ocml_log2
17+
#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, _f32)
18+
#define __CLC_BUILTIN_D __CLC_XCONCAT(__CLC_BUILTIN, _f64)
19+
#include <math/unary_builtin.inc>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===----------------------------------------------------------------------===//
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+
9+
#include <spirv/spirv.h>
10+
11+
float __ocml_remainder_f32(float,float);
12+
double __ocml_remainder_f64(double,double);
13+
14+
#define __CLC_FUNCTION __spirv_ocl_remainder
15+
#define __CLC_BUILTIN __ocml_remainder
16+
#define __CLC_BUILTIN_F __CLC_XCONCAT(__CLC_BUILTIN, _f32)
17+
#define __CLC_BUILTIN_D __CLC_XCONCAT(__CLC_BUILTIN, _f64)
18+
#include <math/binary_builtin.inc>

libclc/generic/libspirv/SOURCES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ math/nextafter.cl
165165
math/pow.cl
166166
math/pown.cl
167167
math/powr.cl
168-
math/remainer.cl
168+
math/remainder.cl
169169
math/remquo.cl
170170
math/rint.cl
171171
math/rootn.cl

libclc/ptx-nvidiacl/libspirv/SOURCES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ math/native_sqrt.cl
5555
math/native_tan.cl
5656
math/nextafter.cl
5757
math/pow.cl
58-
math/remainer.cl
58+
math/remainder.cl
5959
math/round.cl
6060
math/rsqrt.cl
6161
math/sin.cl

0 commit comments

Comments
 (0)