[PATCH] D31667: [Sema] Extend GetSignedVectorType to deal with non ExtVector types

Bruno Cardoso Lopes via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 4 09:57:46 PDT 2017


bruno added a comment.

Great! Thanks for improving this.



================
Comment at: include/clang/Sema/Sema.h:9287
                                bool AllowBothBool, bool AllowBoolConversion);
-  QualType GetSignedVectorType(QualType V);
+  QualType GetSignedVectorType(QualType V, bool WantExtVectorType);
   QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS,
----------------
Can you change `WantExtVector`  to `UseExtVector`?


================
Comment at: lib/Sema/SemaExpr.cpp:9719
+// gets picked over long long.
+QualType Sema::GetSignedVectorType(QualType V, bool WantExtVector) {
   const VectorType *VTy = V->getAs<VectorType>();
----------------
Do we really need to pass `WantExtVector` here? Why relying on `V` being ext_vector or generic isn't enough to define `WantExtVector`? 


================
Comment at: lib/Sema/SemaExpr.cpp:9803
   // Return a signed type for the vector.
-  return GetSignedVectorType(vType);
+  return GetSignedVectorType(vType, isExtVectorType);
 }
----------------
So in `getLangOpts().OpenCL` mode we want to get a ext_vec even if `vType` isn't ext_vec? Would that ever happen?


================
Comment at: lib/Sema/SemaExpr.cpp:9821
+
+  return GetSignedVectorType(LHS.get()->getType(), isExtVectorType);
 }
----------------
Same question applies here


================
Comment at: lib/Sema/SemaExpr.cpp:11760
       // Vector logical not returns the signed variant of the operand type.
-      resultType = GetSignedVectorType(resultType);
+      resultType = GetSignedVectorType(resultType, true);
       break;
----------------
Use the idiom `...(resultType, true/*WantExtVector*/);`


================
Comment at: test/Sema/vector-ops.c:16
   // Comparison operators
-  v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'int __attribute__((ext_vector_type(2)))' (vector of 2 'int' values)}}
+  v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values)}}
   v2sa = (v2ua==v2sa);
----------------
Can you also add a test for the `CheckVectorLogicalOperands` case?


https://reviews.llvm.org/D31667





More information about the cfe-commits mailing list