[Alias] isNoAlias don't return expect result when we override pointer

hi,
I had a problem, for the following case, the %fi is a local stack address, and the %P is a function argument pointer, so they are no alias, the API AA->isNoAlias also get expected result true.

But when I add two IR , which use “store i64 %poisonptr, i64** %P, align 4” to override the %P , then it is very strange, and still returns result true ?

; RUN: opt < %s -memcpyopt -S -verify-memoryssa | FileCheck %s

target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"

define void @foo(i64** nocapture %P) {
entry:
  %fi = alloca [12 x float], align 8
  %arrayidx47= getelementptr inbounds [12 x float], [12 x float]* %fi, i64 0, i64 0

  ; %poisonptr = bitcast [12 x float]* %fi to i64*
  ; store i64* %poisonptr, i64** %P, align 4  ; override the pointer %P

  %0 = bitcast i64** %P to i16*
  %arrayidx = getelementptr inbounds i16, i16* %0, i64 1
  %1 = bitcast i16* %arrayidx to i32*
  %arrayidx1 = getelementptr inbounds i16, i16* %0, i64 3
  store i16 0, i16* %0, align 2
  store float 0.000000e+00, float* %arrayidx47, align 8
  store i32 0, i32* %1, align 4  
  store i16 0, i16* %arrayidx1, align 2
  ret void
}**strong text**
(gdb) p Inst->dump()
  store float 0.000000e+00, float* %arrayidx47, align 8
$12 = void
(gdb) p StartInst->dump()
  store i16 0, i16* %0, align 2
  • need pass the pointer address, but not the memory access instruction itself

AA->isNoAlias(Inst->getPointerOperand(), StartInst->getPointerOperand())

When you write store i64* %poisonptr, i64** %P, you are not overriding the value of %P–you are overriding the value in the memory location %P points to.

1 Like

Yes, the above comment is now accuracy, thanks for your attenion.

additional, %0 = bitcast i64 %P to i16*** should be replaced with %0 = load i64, i64* %P , align 8**, then we’ll get false with isNoAlias(Inst->getPointerOperand(), StartInst->getPointerOperand())