[PATCH] D24472: [Sema] Support lax conversions for compound assignments
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 30 09:52:28 PDT 2016
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.
> + // type. Note that this is already done by non-compound assignments in
> + // CheckAssignmentConstraints. If it's a scalar type, only biscast for
> + // <1 x T> -> T. The result is also a vector type.
typo on biscast
> bruno wrote in SemaExpr.cpp:8090
> You're right, the diagnostics are bad here, this patch adds some FIXMEs so we can later work on it. A PR would be nice though (we have an internal track for that as well, see rdar://problem/28067874).
> Given your example:
> a = a + b; // clang accepts this.
> a += b; // currently clang rejects this.
> IMO, clang should reject `a = a + b` too if not in OpenCL mode, which means whenever (a) `a` and `b` have same size but different num elt and (b) `a` and `b` are generic vectors (non ext-vectors). However, It looks like we have tests that rely on this behavior, we should probably find out why first and clean it up.
> I also think we should support splatting when one of the operands is a scalar and the other a non ext-vector (as of now we currently only do it for OpenCL). This is basically what GCC supports https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html.
I agree. I think the way forward is to:
- Allow conversions between `<1 x T>` and scalar `T` without enabling lax vector conversions. This seems pretty unobjectionable.
- Disable lax vector conversions by default, and evaluate whether they can be completely removed.
More information about the cfe-commits