[llvm] [InstCombine] Add assumption to preserve deref info after sinking. (PR #120888)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 22 07:16:37 PST 2024


================
@@ -4872,6 +4873,16 @@ bool InstCombinerImpl::tryToSinkInstruction(Instruction *I,
   /// the new position.
 
   BasicBlock::iterator InsertPos = DestBlock->getFirstInsertionPt();
+
+  if (!CleanupAssumptions && isa<LoadInst>(I)) {
+    // Preserve dereferenceable at original position.
+    // TODO: Only need to add this extra information if I doesn't always execute
+    // in the new position.
+    Builder.SetInsertPoint(I);
+    Value *Ptr = I->getOperand(0);
+    Builder.CreateDereferenceableAssumption(
+        Ptr, I->getType()->getScalarSizeInBits());
----------------
dtcxzyw wrote:

Loads of vectors and pointers are not handled here.


https://github.com/llvm/llvm-project/pull/120888


More information about the llvm-commits mailing list