Skip to content

Commit a305edf

Browse files
[SYCL-MLIR] Handle __builtin_assume (#7250)
Generate `LLVM::AssumeOp` for `BI__builtin_assume`. Signed-off-by: Tsang, Whitney <[email protected]>
1 parent 5856ee2 commit a305edf

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

polygeist/tools/cgeist/Lib/CGCall.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,13 @@ ValueCategory MLIRScanner::VisitCallExpr(clang::CallExpr *expr) {
630630
return val;
631631
};
632632

633+
switch (expr->getBuiltinCallee()) {
634+
case clang::Builtin::BI__builtin_assume:
635+
mlir::Value V0 = getLLVM(expr->getArg(0));
636+
return ValueCategory(builder.create<LLVM::AssumeOp>(loc, V0)->getResult(0),
637+
false);
638+
};
639+
633640
if (auto *ic = dyn_cast<ImplicitCastExpr>(expr->getCallee()))
634641
if (auto *sr = dyn_cast<DeclRefExpr>(ic->getSubExpr())) {
635642
if (sr->getDecl()->getIdentifier() &&

polygeist/tools/cgeist/Lib/clang-mlir.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,7 @@ ValueCategory MLIRScanner::VisitBinaryOperator(clang::BinaryOperator *BO) {
18061806
} else {
18071807
res = builder.create<arith::CmpIOp>(loc, IPred, lhs_v, rhs_v);
18081808
}
1809-
return fixInteger(res);
1809+
return ValueCategory(res, /*isReference*/ false);
18101810
}
18111811

18121812
case clang::BinaryOperator::Opcode::BO_Comma: {

polygeist/tools/cgeist/Test/Verification/sycl/parallel_for.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// Test that all referenced sycl header functions are generated.
1212
// RUN: llvm-dis %t.bc
13-
// RUN: cat %t.ll | FileCheck %s --check-prefix=LLVM --implicit-check-not="declare{{.*}}spir_func{{^__builtin_}}"
13+
// RUN: cat %t.ll | FileCheck %s --check-prefix=LLVM --implicit-check-not="declare{{.*}}spir_func"
1414

1515
// Test that the kernel named `kernel_parallel_for` is generated with the correct signature.
1616
// LLVM: define weak_odr spir_kernel void {{.*}}kernel_parallel_for(
@@ -38,10 +38,7 @@ void host_parallel_for(std::array<int, N> &A) {
3838
}
3939

4040
int main() {
41-
std::array<int, N> A;
42-
for (unsigned i = 0; i < N; ++i) {
43-
A[i] = 0;
44-
}
41+
std::array<int, N> A{0};
4542
host_parallel_for(A);
4643
for (unsigned i = 0; i < N; ++i) {
4744
assert(A[i] == i);

0 commit comments

Comments
 (0)