[PATCH] D108848: [LoopDeletion] Separate logic in breakBackedgeIfNotTaken using symboic max trip count [nfc]

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 17 10:36:39 PST 2022


fhahn added a comment.

In D108848#3147643 <https://reviews.llvm.org/D108848#3147643>, @reames wrote:

> In D108848#3138354 <https://reviews.llvm.org/D108848#3138354>, @xbolva00 wrote:
>
>> Not NFC?
>>
>> https://bugs.llvm.org/show_bug.cgi?id=52535
>
> Took a quick look at this.  No obvious relation, I'd guess some type of pass ordering and/or analysis invalidation.  If you can reduce me something which changes behavior with this pass, I'll take another look.

Looks like another potential code change has been tracked down to this commit.

For the reproducer below, `loop-deletion` replaces the branch in `for.inc8` with an unconditional one with the patch reverted:

  > for.inc8:                                         ; preds = %for.inc8.loopexit, %for.cond4thread-pre-split
  31c40
  <   br i1 %exitcond.not, label %cleanup, label %for.body, !llvm.loop !11
  ---
  >   br label %cleanup



  @a = internal unnamed_addr global i1 false, align 4
  @b = internal unnamed_addr global i32 0, align 4
  
  define i32 @main() {
  entry:
    br label %for.body
  
  for.body:                                         ; preds = %entry, %for.inc8
    %d.015 = phi i32 [ 0, %entry ], [ %inc9, %for.inc8 ]
    %.b = load i1, i1* @a, align 4
    %conv1 = select i1 %.b, i32 -128, i32 1
    %cmp2.not = icmp ugt i32 %conv1, %d.015
    br i1 %cmp2.not, label %cleanup, label %for.cond4thread-pre-split
  
  for.cond4thread-pre-split:                        ; preds = %for.body
    %.pr = load i32, i32* @b, align 4
    %cmp514 = icmp slt i32 %.pr, 1
    br i1 %cmp514, label %for.body7, label %for.inc8
  
  for.body7:                                        ; preds = %for.cond4thread-pre-split, %for.body7
    tail call void @foo() #2
    %0 = load i32, i32* @b, align 4
    %inc = add nsw i32 %0, 1
    store i32 %inc, i32* @b, align 4
    %cmp5 = icmp slt i32 %0, 0
    br i1 %cmp5, label %for.body7, label %for.inc8, !llvm.loop !9
  
  for.inc8:                                         ; preds = %for.body7, %for.cond4thread-pre-split
    %inc9 = add nuw nsw i32 %d.015, 1
    %exitcond.not = icmp eq i32 %inc9, 19
    br i1 %exitcond.not, label %cleanup, label %for.body, !llvm.loop !11
  
  cleanup:                                          ; preds = %for.body, %for.inc8
    store i1 true, i1* @a, align 4
    ret i32 0
  }
  
  declare void @foo() local_unnamed_addr #1
  
  !9 = distinct !{!9, !10}
  !10 = !{!"llvm.loop.mustprogress"}
  !11 = distinct !{!11, !10}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108848



More information about the llvm-commits mailing list