<div dir="ltr">Might as well roll the if check into the assert at that point? (assert(!isa<T>(...) || (cast<T>(x) == blah)... etc)</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 22, 2020 at 6:58 AM Sander de Smalen via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Author: Sander de Smalen<br>
Date: 2020-04-22T14:57:28+01:00<br>
New Revision: 78aa260df742bc1fbe252bffdb7a1da0613ef116<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/78aa260df742bc1fbe252bffdb7a1da0613ef116" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/78aa260df742bc1fbe252bffdb7a1da0613ef116</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/78aa260df742bc1fbe252bffdb7a1da0613ef116.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/78aa260df742bc1fbe252bffdb7a1da0613ef116.diff</a><br>
<br>
LOG: [NFC] Fix unused result of dyn_cast<VectorType> in non-assert build<br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
    llvm/lib/IR/Constants.cpp<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp<br>
index 338029fa00de..b86b747f7519 100644<br>
--- a/llvm/lib/IR/Constants.cpp<br>
+++ b/llvm/lib/IR/Constants.cpp<br>
@@ -1895,8 +1895,8 @@ Constant *ConstantExpr::getPtrToInt(Constant *C, Type *DstTy,<br>
   assert(DstTy->isIntOrIntVectorTy() &&<br>
          "PtrToInt destination must be integer or integer vector");<br>
   assert(isa<VectorType>(C->getType()) == isa<VectorType>(DstTy));<br>
-  if (auto *CVTy = dyn_cast<VectorType>(C->getType()))<br>
-    assert(CVTy->getNumElements() ==<br>
+  if (isa<VectorType>(C->getType()))<br>
+    assert(cast<VectorType>(C->getType())->getNumElements() ==<br>
                cast<VectorType>(DstTy)->getNumElements() &&<br>
            "Invalid cast between a <br>
diff erent number of vector elements");<br>
   return getFoldedCast(Instruction::PtrToInt, C, DstTy, OnlyIfReduced);<br>
@@ -1909,8 +1909,8 @@ Constant *ConstantExpr::getIntToPtr(Constant *C, Type *DstTy,<br>
   assert(DstTy->isPtrOrPtrVectorTy() &&<br>
          "IntToPtr destination must be a pointer or pointer vector");<br>
   assert(isa<VectorType>(C->getType()) == isa<VectorType>(DstTy));<br>
-  if (auto *CVTy = dyn_cast<VectorType>(C->getType()))<br>
-    assert(CVTy->getNumElements() ==<br>
+  if (isa<VectorType>(C->getType()))<br>
+    assert(cast<VectorType>(C->getType())->getNumElements() ==<br>
                cast<VectorType>(DstTy)->getNumElements() &&<br>
            "Invalid cast between a <br>
diff erent number of vector elements");<br>
   return getFoldedCast(Instruction::IntToPtr, C, DstTy, OnlyIfReduced);<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>