================
@@ -428,6 +431,85 @@ Value *VPInstruction::generatePerPart(VPTransformState 
&State, unsigned Part) {
                                    {PredTy, ScalarTC->getType()},
                                    {VIVElem0, ScalarTC}, nullptr, Name);
   }
+  case VPInstruction::AliasLaneMask: {
+    // Given a pointer A that is being stored to, and pointer B that is being
+    // read from, both with unknown lengths, create a mask that disables
+    // elements which could overlap across a loop iteration. For example, if A
+    // is X and B is X + 2 with VF being 4, only the final two elements of the
+    // loaded vector can be stored since they don't overlap with the stored
+    // vector. %b.vec = load %b ; = [s, t, u, v]
+    // [...]
+    // store %a, %b.vec ; only u and v can be stored as their addresses don't
+    // overlap with %a + (VF - 1)
+    Value *ReadPtr = State.get(getOperand(0), VPIteration(Part, 0));
+    Value *StorePtr = State.get(getOperand(1), VPIteration(Part, 0));
+    unsigned ElementSize = 0;
+
+    // We expect the operands to the alias mask to be ptrtoint. Sometimes it's
+    // an add of a ptrtoint.
+    auto *ReadInsn = cast<Instruction>(ReadPtr);
+    auto *ReadCast = dyn_cast<CastInst>(ReadPtr);
+    if (ReadInsn->getOpcode() == Instruction::Add)
+      ReadCast = dyn_cast<CastInst>(ReadInsn->getOperand(0));
+
+    if (ReadCast && ReadCast->getOpcode() == Instruction::PtrToInt) {
+      Value *Ptr = ReadCast->getOperand(0);
+      for (auto *Use : Ptr->users()) {
----------------
SamTebbs33 wrote:

@fhahn  I'm not sure if figuring out the element size before execution time 
will work since at that point the source and destination pointers are SCEVS and 
the users of the pointers themselves aren't available. The SCEVs have to be 
expanded before that information is available. Do you have any pointers to help 
with this?

https://github.com/llvm/llvm-project/pull/100579
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to