Skip to content

Commit

Permalink
[SYCL][ESIMD] Remove optnone from ESIMD functions (#11986)
Browse files Browse the repository at this point in the history
Previously we never had optnone in the SPIR-V due to the issue in
993fe5b,
but with that fixed we started seeing it and that broke some O0 tests.

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
  • Loading branch information
sarnex authored Nov 28, 2023
1 parent 5a51c0a commit 00a7e36
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions llvm/lib/SYCLLowerIR/ESIMD/LowerESIMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,17 @@ size_t SYCLLowerESIMDPass::runOnFunction(Function &F,
SmallVector<CallInst *, 32> ESIMDIntrCalls;
SmallVector<Instruction *, 8> ToErase;

// The VC backend doesn't support debugging, and trying to use
// non-optimized code often produces crashes or wrong answers.
// The recommendation from the VC team was always optimize code,
// even if the user requested no optimization. We already drop
// debugging flags in the SYCL runtime, so also drop optnone and
// noinline here.
if (isESIMD(F) && F.hasFnAttribute(Attribute::OptimizeNone)) {
F.removeFnAttr(Attribute::OptimizeNone);
F.removeFnAttr(Attribute::NoInline);
}

for (Instruction &I : instructions(F)) {
if (auto CastOp = dyn_cast<llvm::CastInst>(&I)) {
llvm::Type *DstTy = CastOp->getDestTy();
Expand Down
20 changes: 20 additions & 0 deletions llvm/test/SYCLLowerIR/ESIMD/optnone.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; This ensures we remove optnone from ESIMD functions
; RUN: opt < %s -passes=LowerESIMD -S | FileCheck %s

target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
target triple = "spir64-unknown-unknown"

define dso_local spir_func void @esimd() #0 !sycl_explicit_simd !0 {
; CHECK: void @esimd() #[[#ESIMDAttr:]]
ret void
}

define dso_local spir_func void @sycl() #0 {
; CHECK: spir_func void @sycl() #[[#SYCLAttr:]]
ret void
}
; CHECK: attributes #[[#ESIMDAttr]] =
; CHECK-NOT: optnone
; CHECK: attributes #[[#SYCLAttr]] = {{{.*}}optnone{{.*}}}
attributes #0 = { noinline optnone convergent }
!0 = !{}

0 comments on commit 00a7e36

Please sign in to comment.