[PATCH] D27569: [OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.
Egor Churaev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 8 02:14:35 PST 2016
echuraev created this revision.
echuraev added a reviewer: Anastasia.
echuraev added subscribers: bader, yaxunl, cfe-commits.
Enabling the compression of CLK_NULL_QUEUE to variable of type queue_t.
https://reviews.llvm.org/D27569
Files:
lib/Sema/SemaExpr.cpp
test/CodeGenOpenCL/null_queue.cl
Index: test/CodeGenOpenCL/null_queue.cl
===================================================================
--- /dev/null
+++ test/CodeGenOpenCL/null_queue.cl
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -emit-llvm %s -o - | FileCheck %s
+extern queue_t get_default_queue();
+
+#define CLK_NULL_QUEUE 0
+
+bool f() {
+ return CLK_NULL_QUEUE == get_default_queue() &&
+ get_default_queue() == CLK_NULL_QUEUE;
+ // CHECK: icmp eq %opencl.queue_t* null, %{{.*}}
+}
+
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -9621,6 +9621,18 @@
return ResultTy;
}
+ if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200) {
+ if (LHSIsNull && RHSType->isQueueT()) {
+ LHS = ImpCastExprToType(LHS.get(), RHSType, CK_NullToPointer);
+ return ResultTy;
+ }
+
+ if (LHSType->isQueueT() && RHSIsNull) {
+ RHS = ImpCastExprToType(RHS.get(), LHSType, CK_NullToPointer);
+ return ResultTy;
+ }
+ }
+
return InvalidOperands(Loc, LHS, RHS);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27569.80733.patch
Type: text/x-patch
Size: 1103 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161208/bdc82205/attachment.bin>
More information about the cfe-commits
mailing list