[PATCH] D24472: [Sema] Support lax conversions for compound assignments

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 19 12:58:44 PDT 2016


bruno marked an inline comment as done.

================
Comment at: lib/Sema/SemaExpr.cpp:8084
@@ +8083,3 @@
+      *RHSExpr = ImpCastExprToType(RHSExpr->get(), LHSType, CK_BitCast);
+      return LHSType;
+    }
----------------
ahatanak wrote:
> My understanding is that, when we have a compound assign like "LHS += RHS", this function (CheckVectorOperands) is supposed to return the result type (LHS + RHS). However, it is returning different types for "<1 x T> += T"  and "T += <1 x T>" (the former returns <1 x T> and the latter returns T). Would CheckAssignmentOperands reject the compound statement if you returned the vector type here?
> 
> Also, are you planning to allow the same kind of conversions done above for non-compound assignment statements (e.g., <4 x short> += <2 x int>) in the future?
1) CheckAssignmentOperands doesn't reject the compound statement if we return the vector type instead, because it already supports vector to scalar cast idiom. It makes more sense to return a vector indeed, gonna change that.

2) It would be nice to catch up with GCC with the idioms supported for regular (non-ext) vectors (like splatting scalar operands to vectors in a arith binops), and those, AFAIK, don't include support for truncation as in the example you suggested. I guess this is supported with ext-vectors, but I don't see any reason to support it for "regular" vectors.


https://reviews.llvm.org/D24472





More information about the cfe-commits mailing list