Pol Marcet =?utf-8?q?Sardà?= <polmarcetsa...@gmail.com>,
Pol Marcet =?utf-8?q?Sardà?= <polmarcetsa...@gmail.com>,Pol M
 <polmarcetsa...@gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/76...@github.com>


================
@@ -10895,6 +10899,132 @@ bool VectorExprEvaluator::VisitUnaryOperator(const 
UnaryOperator *E) {
   return Success(APValue(ResultElements.data(), ResultElements.size()), E);
 }
 
+static bool EvaluateVectorOrLValue(APValue &Result, EvalInfo &Info,
+                                   const Expr *E, const QualType &Type) {
+  if (!Evaluate(Result, Info, E))
+    return false;
+
+  if (Result.isLValue()) {
+    // Source of the data is an lvalue; Manually handle the lvalue as if
+    // it was an rvalue to get the current APValue.
+    LValue LValueFound;
+    LValueFound.setFrom(Info.Ctx, Result);
+    if (!handleLValueToRValueConversion(Info, E, Type, LValueFound, Result))
+      return false;
+  }
+
+  return Result.isVector();
+}
+
+static bool handleVectorConversion(EvalInfo &Info, const FPOptions FPO,
+                                   const Expr *E, QualType SourceTy,
+                                   QualType DestTy, APValue const &Original,
+                                   APValue &Result) {
+  if (SourceTy->isIntegerType()) {
+    if (DestTy->isRealFloatingType()) {
+      Result = APValue(APFloat(0.0));
+      return HandleIntToFloatCast(Info, E, FPO, SourceTy, Original.getInt(),
+                                  DestTy, Result.getFloat());
----------------
Destroyerrrocket wrote:

I think that beyond some differences in memory layout, I'd expect the 
performance to be about the same for the normal case. The bad case might be 
able to save a bit of performance by avoiding a copy (happening inside the 
APValue) (that probably will get optimized anyway). Without measuring, I think 
this is performant enough, and I value code being short and easy enough to read 
(not that the proposed code is bad in any way; If I saw it in a PR I wouldn't 
even blink)

https://github.com/llvm/llvm-project/pull/76615
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to