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

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 17 18:26:09 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.
----------------
yronglin wrote:

Yeah, I tried to remove this, and use the generic code path(evaluate LHS first), there are no test failures. Here just following what the current interpreter does. But seems it's unnecessary, should remove this?

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


More information about the cfe-commits mailing list