[llvm] [Verifier] Make lrint and lround intrinsic cases concise. NFC (PR #105676)

Sumanth Gundapaneni via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 22 08:11:44 PDT 2024


https://github.com/sgundapa created https://github.com/llvm/llvm-project/pull/105676

None

>From 1aafb65b52aff23dc8b71be683f9083cd8467664 Mon Sep 17 00:00:00 2001
From: Sumanth Gundapaneni <sumanth.gundapaneni at amd.com>
Date: Thu, 22 Aug 2024 10:08:32 -0500
Subject: [PATCH] [Verifier] Make lrint and lround intrinsic cases concise. NFC

---
 llvm/lib/IR/Verifier.cpp | 39 +++++++++------------------------------
 1 file changed, 9 insertions(+), 30 deletions(-)

diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index c095e47996ba17..ac754b5d9638d9 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -5952,44 +5952,23 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
     break;
   }
   case Intrinsic::lrint:
-  case Intrinsic::llrint: {
-    Type *ValTy = Call.getArgOperand(0)->getType();
-    Type *ResultTy = Call.getType();
-    Check(
-        ValTy->isFPOrFPVectorTy() && ResultTy->isIntOrIntVectorTy(),
-        "llvm.lrint, llvm.llrint: argument must be floating-point or vector "
-        "of floating-points, and result must be integer or vector of integers",
-        &Call);
-    Check(ValTy->isVectorTy() == ResultTy->isVectorTy(),
-          "llvm.lrint, llvm.llrint: argument and result disagree on vector use",
-          &Call);
-    if (ValTy->isVectorTy()) {
-      Check(cast<VectorType>(ValTy)->getElementCount() ==
-                cast<VectorType>(ResultTy)->getElementCount(),
-            "llvm.lrint, llvm.llrint: argument must be same length as result",
-            &Call);
-    }
-    break;
-  }
+  case Intrinsic::llrint:
   case Intrinsic::lround:
   case Intrinsic::llround: {
     Type *ValTy = Call.getArgOperand(0)->getType();
     Type *ResultTy = Call.getType();
     auto *VTy = dyn_cast<VectorType>(ValTy);
     auto *RTy = dyn_cast<VectorType>(ResultTy);
-    Check(
-        ValTy->isFPOrFPVectorTy() && ResultTy->isIntOrIntVectorTy(),
-        "llvm.lround, llvm.llround: argument must be floating-point or vector "
-        "of floating-points, and result must be integer or vector of integers",
-        &Call);
-    Check(
-        ValTy->isVectorTy() == ResultTy->isVectorTy(),
-        "llvm.lround, llvm.llround: argument and result disagree on vector use",
-        &Call);
+    Check(ValTy->isFPOrFPVectorTy() && ResultTy->isIntOrIntVectorTy(),
+          ExpectedName + ": argument must be floating-point or vector "
+                         "of floating-points, and result must be integer or "
+                         "vector of integers",
+          &Call);
+    Check(ValTy->isVectorTy() == ResultTy->isVectorTy(),
+          ExpectedName + ": argument and result disagree on vector use", &Call);
     if (VTy) {
       Check(VTy->getElementCount() == RTy->getElementCount(),
-            "llvm.lround, llvm.llround: argument must be same length as result",
-            &Call);
+            ExpectedName + ": argument must be same length as result", &Call);
     }
     break;
   }



More information about the llvm-commits mailing list