[clang] [clang][bytecode] Implement arithmetic, bitwise and compound assignment operator (PR #108949)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 17 09:02:43 PDT 2024


================
@@ -1281,26 +1277,67 @@ bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) {
   const Expr *LHS = E->getLHS();
   const Expr *RHS = E->getRHS();
   const auto *VecTy = E->getType()->getAs<VectorType>();
+  auto Op = E->isCompoundAssignmentOp()
+                ? BinaryOperator::getOpForCompoundAssignment(E->getOpcode())
+                : E->getOpcode();
 
   // The LHS and RHS of a comparison operator must have the same type. So we
   // just use LHS vector element type here.
   PrimType ElemT = this->classifyVectorElementType(LHS->getType());
   PrimType ResultElemT = this->classifyVectorElementType(E->getType());
 
-  // Evaluate LHS and save value to LHSOffset.
+  // Allocate a local pointer for LHS and RHS.
   unsigned LHSOffset = this->allocateLocalPrimitive(LHS, PT_Ptr, true, false);
+  unsigned RHSOffset = this->allocateLocalPrimitive(RHS, PT_Ptr, true, false);
+
+  // C++17 onwards require that we evaluate the RHS of the compound
+  // assignment op first.
----------------
tbaederr wrote:

I think this is technically correct - but unless you can write a test case showing that the current interpreter gets this right, I think this is a bit over the top and we don't need it. (In general, we should try to be as close to a drop-in replacement as possible, which sometimes means we should also imitate bugs).

https://github.com/llvm/llvm-project/pull/108949


More information about the cfe-commits mailing list