Take memset_inline into account in analyzeLoadFromClobberingMemInst
authorGuillaume Chatelet <gchatelet@google.com>
Wed, 26 Oct 2022 09:34:34 +0000 (09:34 +0000)
committerTobias Hieta <tobias@hieta.se>
Fri, 28 Oct 2022 07:37:34 +0000 (09:37 +0200)
This appeared in https://reviews.llvm.org/D126903#3884061

Differential Revision: https://reviews.llvm.org/D136752

(cherry picked from commit 1a726cfa83667585dd87a9955ed5e331cad45d18)

llvm/lib/Transforms/Utils/VNCoercion.cpp

index 42be67f..264da21 100644 (file)
@@ -356,9 +356,9 @@ int analyzeLoadFromClobberingMemInst(Type *LoadTy, Value *LoadPtr,
 
   // If this is memset, we just need to see if the offset is valid in the size
   // of the memset..
-  if (MI->getIntrinsicID() == Intrinsic::memset) {
+  if (const auto *memset_inst = dyn_cast<MemSetInst>(MI)) {
     if (DL.isNonIntegralPointerType(LoadTy->getScalarType())) {
-      auto *CI = dyn_cast<ConstantInt>(cast<MemSetInst>(MI)->getValue());
+      auto *CI = dyn_cast<ConstantInt>(memset_inst->getValue());
       if (!CI || !CI->isZero())
         return -1;
     }