[PATCH] D20133: [OpenCL] Fix __builtin_astype for vec3 types.

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 3 14:58:33 PDT 2016


yaxunl added inline comments.

================
Comment at: lib/CodeGen/CGExprScalar.cpp:3394
@@ +3393,3 @@
+  if (NumElementsDst == 4)
+    Args.push_back(llvm::UndefValue::get(CGF.Int32Ty));
+  llvm::Constant *Mask = llvm::ConstantVector::get(Args);
----------------
Anastasia wrote:
> should this be 3 unstead of undef?
3 or undef are both OK here since the 4th component is undefined. undef may be better since if optimizer checks mask first, it knows that the 4th component is undefined without further checking the second operand.

================
Comment at: test/CodeGenOpenCL/as_type.cl:8
@@ +7,3 @@
+
+//CHECK: define spir_func <3 x i8> @f1(<4 x i8> %[[x:.*]])
+//CHECK: %[[astype:.*]] = shufflevector <4 x i8> %[[x]], <4 x i8> undef, <3 x i32> <i32 0, i32 1, i32 2>
----------------
Anastasia wrote:
> So what happens if the number of bytes don't match?
There will be compilation error and diag msg. I will add a sema test.

================
Comment at: test/CodeGenOpenCL/as_type.cl:46
@@ +45,3 @@
+//CHECK: define spir_func i32 @f6(<4 x i8> %[[x:.*]])
+//CHECK: %[[astype]] = bitcast <4 x i8> %[[x]] to i32
+//CHECK: ret i32 %[[astype]]
----------------
Anastasia wrote:
> Would it make sense to check that shufflevector is not generated?
will fix

================
Comment at: test/CodeGenOpenCL/as_type.cl:53
@@ +52,3 @@
+//CHECK: define spir_func <3 x i8> @f7(<3 x i8> %[[x:.*]])
+//CHECK: ret <3 x i8> %[[x]]
+char3 f7(char3 x) {
----------------
Anastasia wrote:
> Could we add CHECK-NOT bitcast here?
will fix


http://reviews.llvm.org/D20133





More information about the cfe-commits mailing list