<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello Pekka,<br>
    <br>
    I had a look at the current CodeGen tests ... they already cover
    valid combinations of vector/scalar operands. The change improves
    Sema to make sure that invalid combinations error out, and valid
    combinations reach CodeGen. So in short, I can't think of any new
    test to add to the CodeGen tests, and we should simply submit the
    new change.<br>
    <br>
    Sameer.<br>
    <br>
    <div class="moz-cite-prefix">On 2/10/2015 10:13 PM, Pekka
      Jääskeläinen wrote:<br>
    </div>
    <blockquote class=" cite" id="mid_54DA352F_5080508_tut_fi"
      cite="mid:54DA352F.5080508@tut.fi" type="cite">Hello,
      <br>
      <br>
      I'm not knowledgeable enough on the Clang internals either (still
      <br>
      learning). Anyways, should this test that code is generated
      <br>
      correctly for <<=, not just that Sema doesn't complain about
      it?
      <br>
      <br>
      Other than this LGTM.
      <br>
      <br>
      Pekka
      <br>
      <br>
      On 02/10/2015 05:54 PM, Sahasrabuddhe, Sameer wrote:
      <br>
      <blockquote class=" cite" id="Cite_2564484" type="cite">Hello
        Jeroen,
        <br>
        <br>
        Thanks for the feedback. Now waiting for an LGTM from Pekka.
        <br>
        <br>
        Sameer.
        <br>
------------------------------------------------------------------------------
        <br>
        *From:* Jeroen Ketema [<a class="moz-txt-link-abbreviated" href="mailto:j.ketema@imperial.ac.uk">j.ketema@imperial.ac.uk</a>]
        <br>
        *Sent:* Tuesday, February 10, 2015 5:25 PM
        <br>
        *To:* Sahasrabuddhe, Sameer
        <br>
        *Cc:* llvm cfe; Tom Stellard; Pekka Jääskeläinen
        <br>
        *Subject:* Re: r228382 - OpenCL: handle shift operator with
        vector operands
        <br>
        <br>
        <br>
        Hi,
        <br>
        <br>
        I’m not knowledgeable enough to review the updated patch, but
        all my test
        <br>
        cases now pass again.
        <br>
        <br>
        Jeroen
        <br>
        <br>
        <blockquote class=" cite" id="Cite_5199777" type="cite">On 09
          Feb 2015, at 11:00, Sameer Sahasrabuddhe
          <<a class="moz-txt-link-abbreviated" href="mailto:sameer.sahasrabuddhe@amd.com">sameer.sahasrabuddhe@amd.com</a>
          <br>
          <a class="moz-txt-link-rfc2396E" href="mailto:sameer.sahasrabuddhe@amd.com"><mailto:sameer.sahasrabuddhe@amd.com></a>> wrote:
          <br>
          <br>
          Hi all,
          <br>
          <br>
          Attached an updated patch that fixes the earlier patch for
          vector shift
          <br>
          operators in OpenCL. Note the new argument "IsCompAssign" for
          function
          <br>
          checkOpenCLVectorShift(), which was not handled in earlier
          patch.
          <br>
          <br>
          Sameer.
          <br>
          <br>
          On 2/6/2015 11:02 PM, Tom Stellard wrote:
          <br>
          <blockquote class=" cite" id="Cite_7752365" type="cite">On
            Fri, Feb 06, 2015 at 04:05:22PM +0000, Sahasrabuddhe, Sameer
            wrote:
            <br>
            <blockquote class=" cite" id="Cite_3111629" type="cite">Hello
              Jeroen,
              <br>
              <br>
              Thanks for pointing this out! I will fix this as soon as
              possible, but in the meantime, request you or anyone with
              commit access to please revert my commit! I do not have
              access to my work computer until Monday morning India
              time. (Reminder to self: *never* commit on a Friday!).
              <br>
            </blockquote>
            Hi,
            <br>
            <br>
            I have reverted this.  Can you add this test case when you
            recommit.
            <br>
            <br>
            Thanks,
            <br>
            Tom
            <br>
            <br>
            <blockquote class=" cite" id="Cite_7696141" type="cite">Sameer.
              <br>
              ________________________________________
              <br>
              From: Jeroen Ketema [<a class="moz-txt-link-abbreviated" href="mailto:j.ketema@imperial.ac.uk">j.ketema@imperial.ac.uk</a>]
              <br>
              Sent: Friday, February 06, 2015 9:15 PM
              <br>
              To: Sahasrabuddhe, Sameer
              <br>
              Cc: llvm cfe
              <br>
              Subject: Re: r228382 - OpenCL: handle shift operator with
              vector operands
              <br>
              <br>
              Hi Sameer,
              <br>
              <br>
              This commit breaks augmented assignment in combination
              with shifting.
              <br>
              <br>
              Consider the following:
              <br>
              <br>
              typedef __attribute__((ext_vector_type(3))) char char3;
              <br>
              <br>
              void foo() {
              <br>
                char3 v = {1,1,1};
              <br>
                char3 w = {1,2,3};
              <br>
              <br>
                w <<= v;
              <br>
              }
              <br>
              <br>
              If I compile with:
              <br>
              <br>
                clang -x cl file.c
              <br>
              <br>
              Then an error is produced:
              <br>
              <br>
              file.c:10:5: error: expression is not assignable
              <br>
                w <<= v;
              <br>
                ~ ^
              <br>
              1 error generated.
              <br>
              <br>
              This while the OpenCL 1.2 spec says that “w <<= v”
              is short for “w = w << v”,
              <br>
              and which does not produce an error.
              <br>
              <br>
              Thanks,
              <br>
              <br>
              Jeroen
              <br>
              <br>
              <blockquote class=" cite" id="Cite_9282131" type="cite">On
                06 Feb 2015, at 05:44, Sameer Sahasrabuddhe
                <sameer.sahasrabuddhe atamd.com 
                <a class="moz-txt-link-rfc2396E" href="http://amd.com"><http://amd.com></a>> wrote:
                <br>
                <br>
                Author: sameerds
                <br>
                Date: Thu Feb  5 23:44:55 2015
                <br>
                New Revision: 228382
                <br>
                <br>
URL:<a class="moz-txt-link-freetext" href="http://llvm.org/viewvc/llvm-project?rev=228382&view=rev">http://llvm.org/viewvc/llvm-project?rev=228382&view=rev</a>
                <br>
                Log:
                <br>
                OpenCL: handle shift operator with vector operands
                <br>
                <br>
                Introduce a number of checks:
                <br>
                1. If LHS is a scalar, then RHS cannot be a vector.
                <br>
                2. Operands must be of integer type.
                <br>
                3. If both are vectors, then the number of elements must
                match.
                <br>
                <br>
                Relax the requirement for "usual arithmetic
                conversions":
                <br>
                When LHS is a vector, a scalar RHS can simply be
                expanded into a
                <br>
                vector; OpenCL does not require that its rank be lower
                than the LHS.
                <br>
                For example, the following code is not an error even if
                the implicit
                <br>
                type of the constant literal is "int".
                <br>
                <br>
                char2 foo(char2 v) { return v << 1; }
                <br>
                <br>
                Consolidate existing tests under CodeGenOpenCL, and add
                more tests
                <br>
                under SemaOpenCL.
                <br>
                <br>
                <br>
                Modified:
                <br>
                   cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
                <br>
                   cfe/trunk/lib/Sema/SemaExpr.cpp
                <br>
                   cfe/trunk/test/CodeGenOpenCL/shifts.cl
                <br>
                   cfe/trunk/test/SemaOpenCL/shifts.cl
                <br>
                <br>
                Modified:
                cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
                <br>
URL:<a class="moz-txt-link-freetext" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=228382&r1=228381&r2=228382&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=228382&r1=228381&r2=228382&view=diff</a>
                <br>
==============================================================================
                <br>
                --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
                (original)
                <br>
                +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
                Thu Feb  5 23:44:55 2015
                <br>
                @@ -2031,6 +2031,8 @@ def
                err_typecheck_vector_not_convertable
                <br>
                  "can't convert between vector values of different size
                (%0 and %1)">;
                <br>
                def err_typecheck_vector_not_convertable_non_scalar :
                Error<
                <br>
                  "can't convert between vector and non-scalar values
                (%0 and %1)">;
                <br>
                +def err_typecheck_vector_lengths_not_equal : Error<
                <br>
                +  "vector operands do not have the same number of
                elements (%0 and %1)">;
                <br>
                def err_ext_vector_component_exceeds_length : Error<
                <br>
                  "vector component access exceeds type %0">;
                <br>
                def err_ext_vector_component_name_illegal : Error<
                <br>
                @@ -4884,6 +4886,8 @@ def err_ivar_reference_type :
                Error<
                <br>
                  "instance variables cannot be of reference type">;
                <br>
                def err_typecheck_illegal_increment_decrement :
                Error<
                <br>
                  "cannot %select{decrement|increment}1 value of type
                %0">;
                <br>
                +def err_typecheck_expect_int : Error<
                <br>
                +  "used type %0 where integer is required">;
                <br>
                def err_typecheck_arithmetic_incomplete_type : Error<
                <br>
                  "arithmetic on a pointer to an incomplete type
                %0">;
                <br>
                def err_typecheck_pointer_arith_function_type :
                Error<
                <br>
                @@ -5047,6 +5051,9 @@ def
                warn_null_in_comparison_operation :
                <br>
                  "comparison between NULL and non-pointer "
                <br>
                  "%select{(%1 and NULL)|(NULL and %1)}0">,
                <br>
                  InGroup<NullArithmetic>;
                <br>
                +def err_shift_rhs_only_vector : Error<
                <br>
                +  "requested shift is a vector of type %0 but the first
                operand is not a "
                <br>
                +  "vector (%1)">;
                <br>
                <br>
                def warn_logical_not_on_lhs_of_comparison : Warning<
                <br>
                  "logical not is only applied to the left hand side of
                this comparison">,
                <br>
                <br>
                Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
                <br>
URL:<a class="moz-txt-link-freetext" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=228382&r1=228381&r2=228382&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=228382&r1=228381&r2=228382&view=diff</a>
                <br>
==============================================================================
                <br>
                --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
                <br>
                +++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Feb  5 23:44:55
                2015
                <br>
                @@ -7772,6 +7772,67 @@ static void
                DiagnoseBadShiftValues(Sema&
                <br>
                    << RHS.get()->getSourceRange();
                <br>
                }
                <br>
                <br>
                +/// \brief Return the resulting type when an OpenCL
                vector is shifted
                <br>
                +///        by a scalar or vector shift amount.
                <br>
                +static QualType checkOpenCLVectorShift(Sema &S,
                <br>
                +                                       ExprResult
                &LHS, ExprResult &RHS,
                <br>
                +                                       SourceLocation
                Loc) {
                <br>
                +  // OpenCL v1.1 s6.3.j says RHS can be a vector only
                if LHS is a vector.
                <br>
                +  if (!LHS.get()->getType()->isVectorType()) {
                <br>
                +    S.Diag(Loc, diag::err_shift_rhs_only_vector)
                <br>
                +      << RHS.get()->getType() <<
                LHS.get()->getType()
                <br>
                +      << LHS.get()->getSourceRange() <<
                RHS.get()->getSourceRange();
                <br>
                +    return QualType();
                <br>
                +  }
                <br>
                +
                <br>
                +  LHS = S.UsualUnaryConversions(LHS.get());
                <br>
                +  if (LHS.isInvalid()) return QualType();
                <br>
                +
                <br>
                +  RHS = S.UsualUnaryConversions(RHS.get());
                <br>
                +  if (RHS.isInvalid()) return QualType();
                <br>
                +
                <br>
                +  QualType LHSType = LHS.get()->getType();
                <br>
                +  const VectorType *LHSVecTy =
                LHSType->getAs<VectorType>();
                <br>
                +  QualType LHSEleType = LHSVecTy->getElementType();
                <br>
                +
                <br>
                +  // Note that RHS might not be a vector.
                <br>
                +  QualType RHSType = RHS.get()->getType();
                <br>
                +  const VectorType *RHSVecTy =
                RHSType->getAs<VectorType>();
                <br>
                +  QualType RHSEleType = RHSVecTy ?
                RHSVecTy->getElementType() : RHSType;
                <br>
                +
                <br>
                +  // OpenCL v1.1 s6.3.j says that the operands need to
                be integers.
                <br>
                +  if (!LHSEleType->isIntegerType()) {
                <br>
                +    S.Diag(Loc, diag::err_typecheck_expect_int)
                <br>
                +      << LHS.get()->getType() <<
                LHS.get()->getSourceRange();
                <br>
                +    return QualType();
                <br>
                +  }
                <br>
                +
                <br>
                +  if (!RHSEleType->isIntegerType()) {
                <br>
                +    S.Diag(Loc, diag::err_typecheck_expect_int)
                <br>
                +      << RHS.get()->getType() <<
                RHS.get()->getSourceRange();
                <br>
                +    return QualType();
                <br>
                +  }
                <br>
                +
                <br>
                +  if (RHSVecTy) {
                <br>
                +    // OpenCL v1.1 s6.3.j says that for vector types,
                the operators
                <br>
                +    // are applied component-wise. So if RHS is a
                vector, then ensure
                <br>
                +    // that the number of elements is the same as
                LHS...
                <br>
                +    if (RHSVecTy->getNumElements() !=
                LHSVecTy->getNumElements()) {
                <br>
                +      S.Diag(Loc,
                diag::err_typecheck_vector_lengths_not_equal)
                <br>
                +        << LHS.get()->getType() <<
                RHS.get()->getType()
                <br>
                +        << LHS.get()->getSourceRange()
                << RHS.get()->getSourceRange();
                <br>
                +      return QualType();
                <br>
                +    }
                <br>
                +  } else {
                <br>
                +    // ...else expand RHS to match the number of
                elements in LHS.
                <br>
                +    QualType VecTy =
                <br>
                +      S.Context.getExtVectorType(RHSEleType,
                LHSVecTy->getNumElements());
                <br>
                +    RHS = S.ImpCastExprToType(RHS.get(), VecTy,
                CK_VectorSplat);
                <br>
                +  }
                <br>
                +
                <br>
                +  return LHSType;
                <br>
                +}
                <br>
                +
                <br>
                // C99 6.5.7
                <br>
                QualType Sema::CheckShiftOperands(ExprResult &LHS,
                ExprResult &RHS,
                <br>
                                                  SourceLocation Loc,
                unsigned Opc,
                <br>
                @@ -7780,8 +7841,11 @@ QualType
                Sema::CheckShiftOperands(ExprRe
                <br>
                <br>
                  // Vector shifts promote their scalar inputs to vector
                type.
                <br>
                  if (LHS.get()->getType()->isVectorType() ||
                <br>
                -      RHS.get()->getType()->isVectorType())
                <br>
                +      RHS.get()->getType()->isVectorType()) {
                <br>
                +    if (LangOpts.OpenCL)
                <br>
                +      return checkOpenCLVectorShift(*this, LHS, RHS,
                Loc);
                <br>
                    return CheckVectorOperands(LHS, RHS, Loc,
                IsCompAssign);
                <br>
                +  }
                <br>
                <br>
                  // Shifts don't perform usual arithmetic conversions,
                they just do integer
                <br>
                  // promotions on each operand. C99 6.5.7p3
                <br>
                <br>
                Modified: cfe/trunk/test/CodeGenOpenCL/shifts.cl
                <br>
URL:<a class="moz-txt-link-freetext" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/shifts.cl?rev=228382&r1=228381&r2=228382&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/shifts.cl?rev=228382&r1=228381&r2=228382&view=diff</a>
                <br>
==============================================================================
                <br>
                --- cfe/trunk/test/CodeGenOpenCL/shifts.cl (original)
                <br>
                +++ cfe/trunk/test/CodeGenOpenCL/shifts.cl Thu Feb  5
                23:44:55 2015
                <br>
                @@ -1,57 +1,73 @@
                <br>
                -// RUN: %clang_cc1 -x cl -O1 -emit-llvm  %s -o -
                -triple x86_64-linux-gnu | FileCheck %s
                <br>
                -// OpenCL essentially reduces all shift amounts to the
                last word-size bits before evaluating.
                <br>
                -// Test this both for variables and constants evaluated
                in the front-end.
                <br>
                +// RUN: %clang_cc1 -x cl -O1 -emit-llvm  %s -o -
                -triple x86_64-linux-gnu | FileCheck %s
                -check-prefix=OPT
                <br>
                +// RUN: %clang_cc1 -x cl -O0 -emit-llvm  %s -o -
                -triple x86_64-linux-gnu | FileCheck %s
                -check-prefix=NOOPT
                <br>
                <br>
                +// OpenCL essentially reduces all shift amounts to the
                last word-size
                <br>
                +// bits before evaluating. Test this both for variables
                and constants
                <br>
                +// evaluated in the front-end.
                <br>
                +
                <br>
                +// OPT: @gtest1 = constant i64 2147483648
                <br>
                +__constant const unsigned long gtest1 = 1UL <<
                31;
                <br>
                +
                <br>
                +// NOOPT: @negativeShift32
                <br>
                +int negativeShift32(int a,int b) {
                <br>
                +  // NOOPT: %array0 = alloca [256 x i8]
                <br>
                +  char array0[((int)1)<<40];
                <br>
                +  // NOOPT: %array1 = alloca [256 x i8]
                <br>
                +  char array1[((int)1)<<(-24)];
                <br>
                <br>
                -//CHECK: @positiveShift32
                <br>
                +  // NOOPT: ret i32 65536
                <br>
                +  return ((int)1)<<(-16);
                <br>
                +}
                <br>
                +
                <br>
                +//OPT: @positiveShift32
                <br>
                int positiveShift32(int a,int b) {
                <br>
                -  //CHECK: [[M32:%.+]] = and i32 %b, 31
                <br>
                -  //CHECK-NEXT: [[C32:%.+]] = shl i32 %a, [[M32]]
                <br>
                +  //OPT: [[M32:%.+]] = and i32 %b, 31
                <br>
                +  //OPT-NEXT: [[C32:%.+]] = shl i32 %a, [[M32]]
                <br>
                  int c = a<<b;
                <br>
                  int d = ((int)1)<<33;
                <br>
                -  //CHECK-NEXT: [[E32:%.+]] = add nsw i32 [[C32]], 2
                <br>
                +  //OPT-NEXT: [[E32:%.+]] = add nsw i32 [[C32]], 2
                <br>
                  int e = c + d;
                <br>
                -  //CHECK-NEXT: ret i32 [[E32]]
                <br>
                +  //OPT-NEXT: ret i32 [[E32]]
                <br>
                  return e;
                <br>
                }
                <br>
                <br>
                -//CHECK: @positiveShift64
                <br>
                +//OPT: @positiveShift64
                <br>
                long positiveShift64(long a,long b) {
                <br>
                -  //CHECK: [[M64:%.+]] = and i64 %b, 63
                <br>
                -  //CHECK-NEXT: [[C64:%.+]] = ashr i64 %a, [[M64]]
                <br>
                +  //OPT: [[M64:%.+]] = and i64 %b, 63
                <br>
                +  //OPT-NEXT: [[C64:%.+]] = ashr i64 %a, [[M64]]
                <br>
                  long c = a>>b;
                <br>
                  long d = ((long)8)>>65;
                <br>
                -  //CHECK-NEXT: [[E64:%.+]] = add nsw i64 [[C64]], 4
                <br>
                +  //OPT-NEXT: [[E64:%.+]] = add nsw i64 [[C64]], 4
                <br>
                  long e = c + d;
                <br>
                -  //CHECK-NEXT: ret i64 [[E64]]
                <br>
                +  //OPT-NEXT: ret i64 [[E64]]
                <br>
                  return e;
                <br>
                }
                <br>
                <br>
                typedef __attribute__((ext_vector_type(4))) int int4;
                <br>
                <br>
                -//CHECK: @vectorVectorTest
                <br>
                +//OPT: @vectorVectorTest
                <br>
                int4 vectorVectorTest(int4 a,int4 b) {
                <br>
                -  //CHECK: [[VM:%.+]] = and <4 x i32> %b, <i32
                31, i32 31, i32 31, i32 31>
                <br>
                -  //CHECK-NEXT: [[VC:%.+]] = shl <4 x i32> %a,
                [[VM]]
                <br>
                +  //OPT: [[VM:%.+]] = and <4 x i32> %b, <i32
                31, i32 31, i32 31, i32 31>
                <br>
                +  //OPT-NEXT: [[VC:%.+]] = shl <4 x i32> %a,
                [[VM]]
                <br>
                  int4 c = a << b;
                <br>
                -  //CHECK-NEXT: [[VF:%.+]] = add <4 x i32>
                [[VC]], <i32 2, i32 4, i32 16, i32 8>
                <br>
                +  //OPT-NEXT: [[VF:%.+]] = add <4 x i32> [[VC]],
                <i32 2, i32 4, i32 16, i32 8>
                <br>
                  int4 d = {1, 1, 1, 1};
                <br>
                  int4 e = {33, 34, -28, -29};
                <br>
                  int4 f = c + (d << e);
                <br>
                -  //CHECK-NEXT: ret <4 x i32> [[VF]]
                <br>
                +  //OPT-NEXT: ret <4 x i32> [[VF]]
                <br>
                  return f;
                <br>
                }
                <br>
                <br>
                -//CHECK: @vectorScalarTest
                <br>
                +//OPT: @vectorScalarTest
                <br>
                int4 vectorScalarTest(int4 a,int b) {
                <br>
                -  //CHECK: [[SP0:%.+]] = insertelement <4 x i32>
                undef, i32 %b, i32 0
                <br>
                -  //CHECK: [[SP1:%.+]] = shufflevector <4 x i32>
                [[SP0]], <4 x i32> undef, <4 x i32>
                zeroinitializer
                <br>
                -  //CHECK: [[VSM:%.+]] = and <4 x i32> [[SP1]],
                <i32 31, i32 31, i32 31, i32 31>
                <br>
                -  //CHECK-NEXT: [[VSC:%.+]] = shl <4 x i32> %a,
                [[VSM]]
                <br>
                +  //OPT: [[SP0:%.+]] = insertelement <4 x i32>
                undef, i32 %b, i32 0
                <br>
                +  //OPT: [[SP1:%.+]] = shufflevector <4 x i32>
                [[SP0]], <4 x i32> undef, <4 x i32>
                zeroinitializer
                <br>
                +  //OPT: [[VSM:%.+]] = and <4 x i32> [[SP1]],
                <i32 31, i32 31, i32 31, i32 31>
                <br>
                +  //OPT-NEXT: [[VSC:%.+]] = shl <4 x i32> %a,
                [[VSM]]
                <br>
                  int4 c = a << b;
                <br>
                -  //CHECK-NEXT: [[VSF:%.+]] = add <4 x i32>
                [[VSC]], <i32 4, i32 4, i32 4, i32 4>
                <br>
                +  //OPT-NEXT: [[VSF:%.+]] = add <4 x i32>
                [[VSC]], <i32 4, i32 4, i32 4, i32 4>
                <br>
                  int4 d = {1, 1, 1, 1};
                <br>
                  int4 f = c + (d << 34);
                <br>
                -  //CHECK-NEXT: ret <4 x i32> [[VSF]]
                <br>
                +  //OPT-NEXT: ret <4 x i32> [[VSF]]
                <br>
                  return f;
                <br>
                }
                <br>
                <br>
                Modified: cfe/trunk/test/SemaOpenCL/shifts.cl
                <br>
URL:<a class="moz-txt-link-freetext" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/shifts.cl?rev=228382&r1=228381&r2=228382&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/shifts.cl?rev=228382&r1=228381&r2=228382&view=diff</a>
                <br>
==============================================================================
                <br>
                --- cfe/trunk/test/SemaOpenCL/shifts.cl (original)
                <br>
                +++ cfe/trunk/test/SemaOpenCL/shifts.cl Thu Feb  5
                23:44:55 2015
                <br>
                @@ -1,17 +1,54 @@
                <br>
                -// RUN: %clang_cc1 -x cl -O0 -emit-llvm  %s -o -
                -triple x86_64-linux-gnu | FileCheck %s
                <br>
                -// OpenCL essentially reduces all shift amounts to the
                last word-size bits before evaluating.
                <br>
                -// Test this both for variables and constants evaluated
                in the front-end.
                <br>
                -
                <br>
                -// CHECK: @gtest1 = constant i64 2147483648
                <br>
                -__constant const unsigned long gtest1 = 1UL <<
                31;
                <br>
                -
                <br>
                -// CHECK: @negativeShift32
                <br>
                -int negativeShift32(int a,int b) {
                <br>
                -  // CHECK: %array0 = alloca [256 x i8]
                <br>
                -  char array0[((int)1)<<40];
                <br>
                -  // CHECK: %array1 = alloca [256 x i8]
                <br>
                -  char array1[((int)1)<<(-24)];
                <br>
                +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
                <br>
                <br>
                -  // CHECK: ret i32 65536
                <br>
                -  return ((int)1)<<(-16);
                <br>
                +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
                <br>
                +
                <br>
                +typedef __attribute__((ext_vector_type(2))) char char2;
                <br>
                +typedef __attribute__((ext_vector_type(3))) char char3;
                <br>
                +
                <br>
                +typedef __attribute__((ext_vector_type(2))) int int2;
                <br>
                +
                <br>
                +typedef __attribute__((ext_vector_type(2))) float
                float2;
                <br>
                +
                <br>
                +// ** Positive tests **
                <br>
                +
                <br>
                +char2 ptest01(char2 c, char s) {
                <br>
                +  return c << s;
                <br>
                +}
                <br>
                +
                <br>
                +char2 ptest02(char2 c, char2 s) {
                <br>
                +  return c << s;
                <br>
                +}
                <br>
                +
                <br>
                +char2 ptest03(char2 c, int s) {
                <br>
                +  return c << s;
                <br>
                +}
                <br>
                +
                <br>
                +char2 ptest04(char2 c, int2 s) {
                <br>
                +  return c << s;
                <br>
                +}
                <br>
                +
                <br>
                +int2 ptest05(int2 c, char2 s) {
                <br>
                +  return c << s;
                <br>
                +}
                <br>
                +
                <br>
                +char2 ptest06(char2 c) {
                <br>
                +  return c << 1;
                <br>
                +}
                <br>
                +
                <br>
                +// ** Negative tests **
                <br>
                +
                <br>
                +char2 ntest01(char c, char2 s) {
                <br>
                +  return c << s; // expected-error {{requested
                shift is a vector of type 'char2' (vector of 2 'char'
                values) but the first operand is not a vector ('char')}}
                <br>
                +}
                <br>
                +
                <br>
                +char3 ntest02(char3 c, char2 s) {
                <br>
                +  return c << s; // expected-error {{vector
                operands do not have the same number of elements
                ('char3' (vector of 3 'char' values) and 'char2' (vector
                of 2 'char' values))}}
                <br>
                +}
                <br>
                +
                <br>
                +float2 ntest03(float2 c, char s) {
                <br>
                +  return c << s; // expected-error {{used type
                'float2' (vector of 2 'float' values) where integer is
                required}}
                <br>
                +}
                <br>
                +
                <br>
                +int2 ntest04(int2 c, float s) {
                <br>
                +  return c << s; // expected-error {{used type
                'float' where integer is required}}
                <br>
                }
                <br>
                <br>
              </blockquote>
              _______________________________________________
              <br>
              cfe-commits mailing list
              <br>
              <a class="moz-txt-link-abbreviated" href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a>
              <br>
              <a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a>
              <br>
            </blockquote>
          </blockquote>
          <br>
          <br>
          <vector-shift-fixed.patch>
          <br>
        </blockquote>
      </blockquote>
    </blockquote>
    <br>
    <br>
  </body>
</html>