[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 10 14:47:37 PDT 2016


bruno added inline comments.


================
Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8787
     }
+    if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+      const BuiltinType *LHSBT = LHSEleType->getAs<clang::BuiltinType>();
----------------
vbyakovlcl wrote:
> bruno wrote:
> > Besides `__ext_vector_type__`, would this also trigger for `vector_size`? Right now this is an error for `vector_size` primarily because the number of elements is different, can you confirm this won't change?
> I compare vector element sizes, so there must not be any differencies caused by different triggers. I added additional type definitions to the tests. All compiles fain.

I don't think this is right. When I try to compile similar code for `vector_size` without your patch, I get the errors:

/tmp/x.c:80:15: error: vector operands do not have the same number of elements ('vector_int8n' (vector of 2 'int' values) and 'vector_uchar8n' (vector of 8 'unsigned char' values))
  vi8n = vi8n << vuc8n; // expected-warning {{vector operands do not have the same elements sizes}}
         ~~~~ ^  ~~~~~
/tmp/x.c:81:17: error: vector operands do not have the same number of elements ('vector_uchar8n' (vector of 8 'unsigned char' values) and 'vector_int8n' (vector of 2 'int' values))
  vuc8n = vuc8n << vi8n; // expected-warning {{vector operands do not have the same elements sizes}}
          ~~~~~ ^  ~~~~
/tmp/x.c:82:17: error: vector operands do not have the same number of elements ('vector_ushort8n' (vector of 4 'unsigned short' values) and 'vector_uint8n' (vector of 2 'unsigned int' values))
  vus8n = vus8n << vui8n; // expected-warning {{vector operands do not have the same elements sizes}}
          ~~~~~ ^  ~~~~~
/tmp/x.c:83:17: error: vector operands do not have the same number of elements ('vector_uint8n' (vector of 2 'unsigned int' values) and 'vector_short8n' (vector of 4 'short' values))
  vui8n = vui8n << vs8n; // expected-warning {{vector operands do not have the same elements sizes}}
          ~~~~~ ^  ~~~~ 

Given your test changes, it seems that now, instead of "vector operands do not have the same number of elements" we would get "vector operands do not have the same elements sizes". I rather we stay with the first. Additionally, even if we had "vector operands do not have the same elements sizes" for `vector_size`, this should never be demoted to a warning.


https://reviews.llvm.org/D24669





More information about the cfe-commits mailing list