[PATCH] D28909: [InstCombineCalls] Unfold element atomic memcpy instruction

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 8 06:35:21 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL294452: [InstCombineCalls] Remove zero length atomic memcpy intrinsics (authored by igor.laevsky).

Changed prior to commit:
  https://reviews.llvm.org/D28909?vs=85597&id=87647#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28909

Files:
  llvm/trunk/include/llvm/IR/IntrinsicInst.h
  llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp


Index: llvm/trunk/include/llvm/IR/IntrinsicInst.h
===================================================================
--- llvm/trunk/include/llvm/IR/IntrinsicInst.h
+++ llvm/trunk/include/llvm/IR/IntrinsicInst.h
@@ -191,6 +191,32 @@
     }
   };
 
+  /// This class represents atomic memcpy intrinsic
+  /// TODO: Integrate this class into MemIntrinsic hierarchy.
+  class ElementAtomicMemCpyInst : public IntrinsicInst {
+  public:
+    Value *getRawDest() const { return getArgOperand(0); }
+    Value *getRawSource() const { return getArgOperand(1); }
+
+    Value *getNumElements() const { return getArgOperand(2); }
+    void setNumElements(Value *V) { setArgOperand(2, V); }
+
+    uint64_t getSrcAlignment() const { return getParamAlignment(1); }
+    uint64_t getDstAlignment() const { return getParamAlignment(2); }
+
+    uint64_t getElementSizeInBytes() const {
+      Value *Arg = getArgOperand(3);
+      return cast<ConstantInt>(Arg)->getZExtValue();
+    }
+
+    static inline bool classof(const IntrinsicInst *I) {
+      return I->getIntrinsicID() == Intrinsic::memcpy_element_atomic;
+    }
+    static inline bool classof(const Value *V) {
+      return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
+    }
+  };
+
   /// This is the common base class for memset/memcpy/memmove.
   class MemIntrinsic : public IntrinsicInst {
   public:
Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1835,6 +1835,12 @@
     if (Changed) return II;
   }
 
+  if (auto *AMI = dyn_cast<ElementAtomicMemCpyInst>(II)) {
+    if (Constant *C = dyn_cast<Constant>(AMI->getNumElements()))
+      if (C->isNullValue())
+        return eraseInstFromFunction(*AMI);
+  }
+
   if (Instruction *I = SimplifyNVVMIntrinsic(II, *this))
     return I;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28909.87647.patch
Type: text/x-patch
Size: 1970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170208/6af2341e/attachment.bin>


More information about the llvm-commits mailing list