[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

Bruno Cardoso Lopes via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 5 10:07:04 PDT 2017


bruno added inline comments.


================
Comment at: lib/Sema/SemaExpr.cpp:8188
+  //        type and then perform the rest of the checks here. GCC as of
+  //        pre-release 7.0 does not accept this though.
+  if (VectorEltTy->isIntegralType(S.Context) &&
----------------
sdardis wrote:
> bruno wrote:
> > Is this something that GCC is going to support at some point? Regardless of GCC, do we want this behavior?
> > Is this something that GCC is going to support at some point?
> 
> I've reread GCC's source for conversions of scalar to vectors types and it appears that GCC does attempt to convert constant real expressions to integers but it appears to only work for C++. It's a little odd.
> 
> > Regardless of GCC, do we want this behavior?
> 
> Given my oversight of the support of implicit safe conversions of floating point constants to integer types, I believe we should do this in general. I'll rework the comment to be more accurate and add the necessary conversion checks.
Ok, improving the FIXME sounds good to me. We can add this extra functionality in a future patch.


================
Comment at: lib/Sema/SemaExpr.cpp:10019
       isa<ExtVectorType>(vType->getAs<VectorType>()) || getLangOpts().OpenCL;
+  if ((!getLangOpts().CPlusPlus && !getLangOpts().OpenCL) && !isExtVectorType)
+    return InvalidVectorOperands(Loc, LHS, RHS);
----------------
sdardis wrote:
> bruno wrote:
> > Why `!getLangOpts().CPlusPlus` is a requirement here?
> GCC only supports the logical operators &&, ||, ! when compiling C++.
> 
> It's noted near the bottom half of this page: https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html
Ok. It would be nice to find out if there's any actual good reason for it, otherwise we might as well support it for non C++. But no need to block on that; just make sure to annotate these places with FIXMEs so we can work on it in the future. 


https://reviews.llvm.org/D25866





More information about the cfe-commits mailing list