================
@@ -13650,6 +13650,51 @@ static bool getBuiltinAlignArguments(const CallExpr 
*E, EvalInfo &Info,
 
 bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
                                             unsigned BuiltinOp) {
+  auto EvalTestOp =
+      [&](llvm::function_ref<bool(const APInt &, const APInt &)> Fn) {
+        APValue SourceLHS, SourceRHS;
+        if (!EvaluateAsRValue(Info, E->getArg(0), SourceLHS) ||
+            !EvaluateAsRValue(Info, E->getArg(1), SourceRHS))
+          return false;
+
+        unsigned SourceLen = SourceLHS.getVectorLength();
+
+        const VectorType *VT = E->getArg(0)->getType()->castAs<VectorType>();
+        QualType ElemQT = VT->getElementType();
+
+        if (ElemQT->isIntegerType()) {
+          const unsigned LaneWidth =
+              SourceLHS.getVectorElt(0).getInt().getBitWidth();
+          APInt AWide(LaneWidth * SourceLen, 0);
+          APInt BWide(LaneWidth * SourceLen, 0);
+
+          for (unsigned I = 0; I != SourceLen; ++I) {
+            APInt ALane = SourceLHS.getVectorElt(I).getInt();
+            APInt BLane = SourceRHS.getVectorElt(I).getInt();
+            AWide.insertBits(ALane, I * LaneWidth);
+            BWide.insertBits(BLane, I * LaneWidth);
+          }
+          return Success(Fn(AWide, BWide), E);
+
+        } else if (ElemQT->isFloatingType()) {
----------------
RKSimon wrote:

(style) break if-else chain when each block returns:
```
if (ElemQT->isIntegerType()) {
   ....
   return ....
}
if (ElemQT->isFloatingType()) {
   ....
   return ....
}
return false;
```

https://github.com/llvm/llvm-project/pull/160428
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to