r367675 - [OpenCL] Allow OpenCL C style vector initialization in C++

Yvan Roux via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 5 06:14:48 PDT 2019


On Mon, 5 Aug 2019 at 13:16, Anastasia Stulova
<Anastasia.Stulova at arm.com> wrote:
>
> Hi Yvan,
>
>
> Sorry for this, it should now be fixed  in r367823.

Issue fixed, Thanks Anastasia

>
> Thanks,
>
> Anastasia
>
>
>
> ________________________________
> From: Yvan Roux <yvan.roux at linaro.org>
> Sent: 02 August 2019 14:09
> To: Anastasia Stulova <Anastasia.Stulova at arm.com>
> Cc: cfe-commits <cfe-commits at lists.llvm.org>
> Subject: Re: r367675 - [OpenCL] Allow OpenCL C style vector initialization in C++
>
> Hi Anastasia,
>
> This commit broke ARMv8 bots, logs are available here:
>
> http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/14655/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Avector_literals_valid.cl
>
> Thanks,
> Yvan
>
> On Fri, 2 Aug 2019 at 13:18, Anastasia Stulova via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
> >
> > Author: stulova
> > Date: Fri Aug  2 04:19:35 2019
> > New Revision: 367675
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=367675&view=rev
> > Log:
> > [OpenCL] Allow OpenCL C style vector initialization in C++
> >
> > Allow creating vector literals from other vectors.
> >
> >  float4 a = (float4)(1.0f, 2.0f, 3.0f, 4.0f);
> >  float4 v = (float4)(a.s23, a.s01);
> >
> > Differential revision: https://reviews.llvm.org/D65286
> >
> >
> > Removed:
> >     cfe/trunk/test/CodeGenOpenCL/vector_literals_nested.cl
> >     cfe/trunk/test/SemaOpenCL/vector_literals_const.cl
> > Modified:
> >     cfe/trunk/lib/Sema/SemaInit.cpp
> >     cfe/trunk/test/CodeGenOpenCL/vector_literals_valid.cl
> >     cfe/trunk/test/SemaCXX/vector.cpp
> >
> > Modified: cfe/trunk/lib/Sema/SemaInit.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=367675&r1=367674&r2=367675&view=diff
> > ==============================================================================
> > --- cfe/trunk/lib/Sema/SemaInit.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Aug  2 04:19:35 2019
> > @@ -1289,7 +1289,16 @@ void InitListChecker::CheckSubElementTyp
> >      // FIXME: Better EqualLoc?
> >      InitializationKind Kind =
> >          InitializationKind::CreateCopy(expr->getBeginLoc(), SourceLocation());
> > -    InitializationSequence Seq(SemaRef, Entity, Kind, expr,
> > +
> > +    // Vector elements can be initialized from other vectors in which case
> > +    // we need initialization entity with a type of a vector (and not a vector
> > +    // element!) initializing multiple vector elements.
> > +    auto TmpEntity =
> > +        (ElemType->isExtVectorType() && !Entity.getType()->isExtVectorType())
> > +            ? InitializedEntity::InitializeTemporary(ElemType)
> > +            : Entity;
> > +
> > +    InitializationSequence Seq(SemaRef, TmpEntity, Kind, expr,
> >                                 /*TopLevelOfInitList*/ true);
> >
> >      // C++14 [dcl.init.aggr]p13:
> > @@ -1300,8 +1309,7 @@ void InitListChecker::CheckSubElementTyp
> >      // assignment-expression.
> >      if (Seq || isa<InitListExpr>(expr)) {
> >        if (!VerifyOnly) {
> > -        ExprResult Result =
> > -          Seq.Perform(SemaRef, Entity, Kind, expr);
> > +        ExprResult Result = Seq.Perform(SemaRef, TmpEntity, Kind, expr);
> >          if (Result.isInvalid())
> >            hadError = true;
> >
> >
> > Removed: cfe/trunk/test/CodeGenOpenCL/vector_literals_nested.cl
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/vector_literals_nested.cl?rev=367674&view=auto
> > ==============================================================================
> > --- cfe/trunk/test/CodeGenOpenCL/vector_literals_nested.cl (original)
> > +++ cfe/trunk/test/CodeGenOpenCL/vector_literals_nested.cl (removed)
> > @@ -1,23 +0,0 @@
> > -// RUN: %clang_cc1 %s -emit-llvm -O3 -o - | FileCheck %s
> > -
> > -typedef int int2 __attribute((ext_vector_type(2)));
> > -typedef int int4 __attribute((ext_vector_type(4)));
> > -
> > -__constant const int4 itest1 = (int4)(1, 2, ((int2)(3, 4)));
> > -// CHECK: constant <4 x i32> <i32 1, i32 2, i32 3, i32 4>
> > -__constant const int4 itest2 = (int4)(1, 2, ((int2)(3)));
> > -// CHECK: constant <4 x i32> <i32 1, i32 2, i32 3, i32 3>
> > -
> > -typedef float float2 __attribute((ext_vector_type(2)));
> > -typedef float float4 __attribute((ext_vector_type(4)));
> > -
> > -void ftest1(float4 *p) {
> > -  *p = (float4)(1.1f, 1.2f, ((float2)(1.3f, 1.4f)));
> > -// CHECK: store <4 x float> <float 0x3FF19999A0000000, float 0x3FF3333340000000, float 0x3FF4CCCCC0000000, float 0x3FF6666660000000>
> > -}
> > -
> > -float4 ftest2(float4 *p) {
> > -   *p =  (float4)(1.1f, 1.2f, ((float2)(1.3f)));
> > -// CHECK: store <4 x float> <float 0x3FF19999A0000000, float 0x3FF3333340000000, float 0x3FF4CCCCC0000000, float 0x3FF4CCCCC0000000>
> > -}
> > -
> >
> > Modified: cfe/trunk/test/CodeGenOpenCL/vector_literals_valid.cl
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/vector_literals_valid.cl?rev=367675&r1=367674&r2=367675&view=diff
> > ==============================================================================
> > --- cfe/trunk/test/CodeGenOpenCL/vector_literals_valid.cl (original)
> > +++ cfe/trunk/test/CodeGenOpenCL/vector_literals_valid.cl Fri Aug  2 04:19:35 2019
> > @@ -1,22 +1,65 @@
> > -// RUN: %clang_cc1 -emit-llvm %s -o %t
> > +// RUN: %clang_cc1 -emit-llvm %s -o - -O0 | FileCheck %s
> > +// RUN: %clang_cc1 -emit-llvm %s -o - -cl-std=clc++ -O0 | FileCheck %s
> >
> > -typedef __attribute__(( ext_vector_type(2) ))  int int2;
> > -typedef __attribute__(( ext_vector_type(3) ))  int int3;
> > -typedef __attribute__(( ext_vector_type(4) ))  int int4;
> > -typedef __attribute__(( ext_vector_type(8) ))  int int8;
> > -typedef __attribute__(( ext_vector_type(4) ))  float float4;
> > +typedef __attribute__((ext_vector_type(2))) int int2;
> > +typedef __attribute__((ext_vector_type(3))) int int3;
> > +typedef __attribute__((ext_vector_type(4)))  int int4;
> > +typedef __attribute__((ext_vector_type(8)))  int int8;
> > +typedef __attribute__((ext_vector_type(4))) float float4;
> > +
> > +__constant const int4 c1 = (int4)(1, 2, ((int2)(3)));
> > +// CHECK: constant <4 x i32> <i32 1, i32 2, i32 3, i32 3>
> > +
> > +__constant const int4 c2 = (int4)(1, 2, ((int2)(3, 4)));
> > +// CHECK: constant <4 x i32> <i32 1, i32 2, i32 3, i32 4>
> >
> >  void vector_literals_valid() {
> > -  int4 a_1_1_1_1 = (int4)(1,2,3,4);
> > -  int4 a_2_1_1 = (int4)((int2)(1,2),3,4);
> > -  int4 a_1_2_1 = (int4)(1,(int2)(2,3),4);
> > -  int4 a_1_1_2 = (int4)(1,2,(int2)(3,4));
> > -  int4 a_2_2 = (int4)((int2)(1,2),(int2)(3,4));
> > -  int4 a_3_1 = (int4)((int3)(1,2,3),4);
> > -  int4 a_1_3 = (int4)(1,(int3)(2,3,4));
> > +  //CHECK: insertelement <4 x i32> <i32 1, i32 2, i32 undef, i32 undef>, i32 %{{.+}}, i32 2
> > +  //CHECK: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 3
> > +  int4 a_1_1_1_1 = (int4)(1, 2, c1.s2, c2.s3);
> > +
> > +  //CHECK: store <2 x i32> <i32 1, i32 2>, <2 x i32>*
> > +  //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
> > +  //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
> > +  //CHECK: insertelement <4 x i32> %{{.+}}, i32 3, i32 2
> > +  //CHECK: insertelement <4 x i32> %{{.+}}, i32 4, i32 3
> > +  int4 a_2_1_1 = (int4)((int2)(1, 2), 3, 4);
> > +
> > +  //CHECK: store <2 x i32> <i32 2, i32 3>, <2 x i32>*
> > +  //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
> > +  //CHECK: shufflevector <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>, <4 x i32> %{{.+}}, <4 x i32> <i32 0, i32 4, i32 5, i32 undef>
> > +  //CHECK: insertelement <4 x i32> %{{.+}}, i32 4, i32 3
> > +  int4 a_1_2_1 = (int4)(1, (int2)(2, 3), 4);
> > +
> > +  //CHECK: store <2 x i32> <i32 3, i32 4>, <2 x i32>*
> > +  //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
> > +  //CHECK: shufflevector <4 x i32> <i32 1, i32 2, i32 undef, i32 undef>, <4 x i32> %{{.+}}, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
> > +  int4 a_1_1_2 = (int4)(1, 2, (int2)(3, 4));
> > +
> > +  //CHECK: store <2 x i32> <i32 1, i32 2>, <2 x i32>*
> > +  //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
> > +  //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
> > +  //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> <i32 3, i32 3, i32 undef, i32 undef>, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
> > +  int4 a_2_2 = (int4)((int2)(1, 2), (int2)(3));
> > +
> > +  //CHECK: store <4 x i32> <i32 2, i32 3, i32 4, i32 undef>, <4 x i32>*
> > +  //CHECK: shufflevector <4 x i32> %{{.+}}, <4 x i32> undef, <3 x i32> <i32 0, i32 1, i32 2>
> > +  //CHECK: shufflevector <3 x i32> %{{.+}}, <3 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 undef>
> > +  //CHECK: shufflevector <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>, <4 x i32> %{{.+}}, <4 x i32> <i32 0, i32 4, i32 5, i32 6>
> > +  int4 a_1_3 = (int4)(1, (int3)(2, 3, 4));
> > +
> > +  //CHECK: store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %a
> >    int4 a = (int4)(1);
> > -  int8 b = (int8)(1,2,a.xy,a);
> > -  float4 V2 = (float4) (1);
> > -}
> >
> > +  //CHECK: load <4 x i32>, <4 x i32>* %a, align 16
> > +  //CHECK: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> undef, <2 x i32> <i32 0, i32 1>
> > +  //CHECK: shufflevector <2 x i32> %{{[0-9]+}}, <2 x i32> undef, <8 x i32> <i32 0, i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
> > +  //CHECK: shufflevector <8 x i32> <i32 1, i32 2, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>, <8 x i32> %{{.+}}, <8 x i32> <i32 0, i32 1, i32 8, i32 9, i32 undef, i32 undef, i32 undef, i32 undef>
> > +  //CHECK: load <4 x i32>, <4 x i32>* %a, align 16
> > +  //CHECK: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> undef, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
> > +  //CHECK: shufflevector <8 x i32> %{{.+}}, <8 x i32> %{{.+}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11>
> > +  int8 b = (int8)(1, 2, a.xy, a);
> >
> > +  //CHECK: store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, <4 x float>* %V2
> > +  float4 V2 = (float4)(1);
> > +}
> >
> > Modified: cfe/trunk/test/SemaCXX/vector.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/vector.cpp?rev=367675&r1=367674&r2=367675&view=diff
> > ==============================================================================
> > --- cfe/trunk/test/SemaCXX/vector.cpp (original)
> > +++ cfe/trunk/test/SemaCXX/vector.cpp Fri Aug  2 04:19:35 2019
> > @@ -334,3 +334,11 @@ void Init() {
> >  }
> >
> >  } // namespace Templates
> > +
> > +typedef int inte2 __attribute__((__ext_vector_type__(2)));
> > +
> > +void test_vector_literal(inte4 res) {
> > +  inte2 a = (inte2)(1, 2); //expected-warning{{expression result unused}}
> > +  inte4 b = (inte4)(a, a); //expected-error{{C-style cast from vector 'inte2' (vector of 2 'int' values) to vector 'inte4' (vector of 4 'int' values) of different size}} //expected-warning{{expression result unused}}
> > +}
> > +
> >
> > Removed: cfe/trunk/test/SemaOpenCL/vector_literals_const.cl
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/vector_literals_const.cl?rev=367674&view=auto
> > ==============================================================================
> > --- cfe/trunk/test/SemaOpenCL/vector_literals_const.cl (original)
> > +++ cfe/trunk/test/SemaOpenCL/vector_literals_const.cl (removed)
> > @@ -1,27 +0,0 @@
> > -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
> > -// expected-no-diagnostics
> > -
> > -typedef int int2 __attribute((ext_vector_type(2)));
> > -typedef int int3 __attribute((ext_vector_type(3)));
> > -typedef int int4 __attribute((ext_vector_type(4)));
> > -
> > -__constant int4 i_1_1_1_1 = (int4)(1,2,3,4);
> > -__constant int4 i_2_1_1 = (int4)((int2)(1,2),3,4);
> > -__constant int4 i_1_2_1 = (int4)(1,(int2)(2,3),4);
> > -__constant int4 i_1_1_2 = (int4)(1,2,(int2)(3,4));
> > -__constant int4 i_2_2 = (int4)((int2)(1,2),(int2)(3,4));
> > -__constant int4 i_3_1 = (int4)((int3)(1,2,3),4);
> > -__constant int4 i_1_3 = (int4)(1,(int3)(2,3,4));
> > -
> > -typedef float float2 __attribute((ext_vector_type(2)));
> > -typedef float float3 __attribute((ext_vector_type(3)));
> > -typedef float float4 __attribute((ext_vector_type(4)));
> > -
> > -__constant float4 f_1_1_1_1 = (float4)(1,2,3,4);
> > -__constant float4 f_2_1_1 = (float4)((float2)(1,2),3,4);
> > -__constant float4 f_1_2_1 = (float4)(1,(float2)(2,3),4);
> > -__constant float4 f_1_1_2 = (float4)(1,2,(float2)(3,4));
> > -__constant float4 f_2_2 = (float4)((float2)(1,2),(float2)(3,4));
> > -__constant float4 f_3_1 = (float4)((float3)(1,2,3),4);
> > -__constant float4 f_1_3 = (float4)(1,(float3)(2,3,4));
> > -
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list