[PATCH] D153392: [PhaseOrdering] Don't speculate blocks in simplifycfg before jump-threading

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 23 11:02:36 PDT 2023


aeubanks added a comment.

thanks for those patches, they do fix this case, but they don't fix the case with malloc. e.g. the following loop doesn't get unrolled until the very last loop-unroll pass

  define i32 @f() local_unnamed_addr {
  bb:
    %alloc = tail call dereferenceable_or_null(64) ptr @malloc(i64 64)
    store i32 1, ptr %alloc, align 4
    %getelementptr = getelementptr i32, ptr %alloc, i64 1
    store i32 2, ptr %getelementptr, align 4
    %getelementptr1 = getelementptr i32, ptr %alloc, i64 2
    store i32 3, ptr %getelementptr1, align 4
    %getelementptr2 = getelementptr i32, ptr %alloc, i64 3
    br label %bb11.i
  
  bb11.i:                                           ; preds = %bb, %bb11.i
    %phi37.i = phi i32 [ %add.i, %bb11.i ], [ 0, %bb ]
    %phi6.i = phi ptr [ %spec.select.i, %bb11.i ], [ %alloc, %bb ]
    %spec.select.i = getelementptr i32, ptr %phi6.i, i64 1
    %load.i = load i32, ptr %phi6.i, align 4
    %add.i = add i32 %load.i, %phi37.i
    %icmp4.i = icmp ne ptr %spec.select.i, %getelementptr2
    %icmp102.i = icmp ne ptr %spec.select.i, null
    %icmp10.not.i = and i1 %icmp102.i, %icmp4.i
    br i1 %icmp10.not.i, label %bb11.i, label %zot.exit
  
  zot.exit:                                         ; preds = %bb11.i
    tail call void @free(ptr %alloc)
    ret i32 %add.i
  }
  
  ; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
  declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0
  
  ; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
  declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1
  
  attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  attributes #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153392/new/

https://reviews.llvm.org/D153392



More information about the llvm-commits mailing list