[llvm-bugs] [Bug 42143] New: [DA] Aliasing checks in DA are incorrect

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 5 10:15:25 PDT 2019


            Bug ID: 42143
           Summary: [DA] Aliasing checks in DA are incorrect
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: david.green at arm.com
          Reporter: david.green at arm.com
                CC: llvm-bugs at lists.llvm.org

The Aliasing checks in DA currently do this:
  // Check the original locations (minus size) for noalias, which can happen
  // tbaa, incompatible underlying object locations, etc.
  MemoryLocation LocAS(LocA.Ptr, LocationSize::unknown(), LocA.AATags);
  MemoryLocation LocBS(LocB.Ptr, LocationSize::unknown(), LocB.AATags);
  if (AA->alias(LocAS, LocBS) == NoAlias)
    return NoAlias;

  // Check the underlying objects are the same
  const Value *AObj = GetUnderlyingObject(LocA.Ptr, DL);
  const Value *BObj = GetUnderlyingObject(LocB.Ptr, DL);

  // If the underlying objects are the same, they must alias
  if (AObj == BObj)
    return MustAlias;

  // We may have hit the recursion limit for underlying objects, or have
  // underlying objects where we don't know they will alias.
  if (!isIdentifiedObject(AObj) || !isIdentifiedObject(BObj))
    return MayAlias;

  // Otherwise we know the objects are different and both identified objects so
  // must not alias.
  return NoAlias;

The alias check is invalid for cases like this, which will return noalias for
individual loop iterations, but we care about cross-loop dependencies:
define float @f() {
  %g = alloca float, align 4
  %h = alloca float, align 4
  br label %for.body

for.body:                                         ; preds = %for.body, %entry
  %p = phi float* [ %g, %entry ], [ %q, %for.body ]
  %q = phi float* [ %h, %entry ], [ %p, %for.body ]
  %0 = load float, float* %p, align 4
  store float undef, float* %q, align 4
  %branch_cond = fcmp ugt float %0, 0.0
  br i1 %branch_cond, label %for.cond.cleanup, label %for.body

for.cond.cleanup:                                 ; preds = %for.body
  ret float undef

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190605/3aa085de/attachment.html>

More information about the llvm-bugs mailing list