[PATCH] D20665: Claim NoAlias if two GEPs index different fields of the same struct

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 19:29:04 PDT 2016


eli.friedman added a comment.

My example run through "clang -S -emit-llvm -O2 -fno-unroll-loops":

  define void @_Z1fP1A(%struct.A* nocapture %x) #0 {
  entry:
    %b = getelementptr inbounds %struct.A, %struct.A* %x, i64 0, i32 1
    %.pre = load i8, i8* %b, align 1, !tbaa !1
    br label %for.body
  
  for.cond.cleanup:                                 ; preds = %for.body
    ret void
  
  for.body:                                         ; preds = %for.body, %entry
    %0 = phi i8 [ %.pre, %entry ], [ %add, %for.body ]
    %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
    %arrayidx = getelementptr inbounds %struct.A, %struct.A* %x, i64 0, i32 0, i64 %indvars.iv
    %1 = load i8, i8* %arrayidx, align 1, !tbaa !5
    %add = add i8 %0, %1
    store i8 %add, i8* %b, align 1, !tbaa !1
    %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
    %exitcond = icmp eq i64 %indvars.iv.next, 11
    br i1 %exitcond, label %for.cond.cleanup, label %for.body
  }

Note in particular `%b = getelementptr inbounds %struct.A, %struct.A* %x, i64 0, i32 1` vs. `%arrayidx = getelementptr inbounds %struct.A, %struct.A* %x, i64 0, i32 0, i64 %indvars.iv`.


Repository:
  rL LLVM

http://reviews.llvm.org/D20665





More information about the llvm-commits mailing list