[PATCH] D124159: [SimplifyCFG] Thread branches on same condition in more cases (PR54980)

Han-Kuan Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 1 00:51:57 PDT 2022


HanKuanChen added a comment.

HI, the following code get infinite loop after this commit.

  ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
  ; RUN: opt -passes="simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts>" -S < %s | FileCheck %s
  
  define void @_Z10alignedboxl(i1 %cmp.a, i1 %cmp.b, i1 %cmp.c) {
  ; CHECK-LABEL: @_Z10alignedboxl(
  ; CHECK-NEXT:  entry:
  ; CHECK-NEXT:    br label [[WHILE_COND:%.*]]
  ; CHECK:       while.cond:
  ; CHECK-NEXT:    br i1 [[CMP_A:%.*]], label [[FOR:%.*]], label [[WHILE_BODY_THREAD:%.*]]
  ; CHECK:       for.body:
  ; CHECK-NEXT:    br i1 [[CMP_B:%.*]], label [[WHILE_BODY:%.*]], label [[FOR_BODY:%.*]]
  ; CHECK:       for:
  ; CHECK-NEXT:    tail call void @XXX()
  ; CHECK-NEXT:    br label [[FOR_BODY]]
  ; CHECK:       while.body:
  ; CHECK-NEXT:    br i1 [[CMP_C:%.*]], label [[C_EXIT:%.*]], label [[LAND:%.*]]
  ; CHECK:       while.body.thread:
  ; CHECK-NEXT:    br i1 [[CMP_C]], label [[WHILE_COND]], label [[LAND]]
  ; CHECK:       land:
  ; CHECK-NEXT:    tail call void @XXX()
  ; CHECK-NEXT:    br label [[WHILE_COND]]
  ; CHECK:       c.exit:
  ; CHECK-NEXT:    br i1 [[CMP_A]], label [[FOR_D:%.*]], label [[WHILE_BODY_THREAD]]
  ; CHECK:       for.d:
  ; CHECK-NEXT:    ret void
  ;
  entry:
    br label %while.cond
  
  while.cond:                                       ; preds = %land, %while.body.thread, %entry
    br i1 %cmp.a, label %for, label %while.body.thread
  
  for.body:                                         ; preds = %for, %for.body
    br i1 %cmp.b, label %while.body, label %for.body
  
  for:                                              ; preds = %while.cond
    tail call void @XXX()
    br label %for.body
  
  while.body:                                       ; preds = %for.body
    br i1 %cmp.c, label %c.exit, label %land
  
  while.body.thread:                                ; preds = %c.exit, %while.cond
    br i1 %cmp.c, label %while.cond, label %land
  
  land:                                             ; preds = %while.body.thread, %while.body
    tail call void @XXX()
    br label %while.cond
  
  c.exit:                                           ; preds = %while.body
    br i1 %cmp.a, label %for.d, label %while.cond
  
  for.d:                                            ; preds = %c.exit
    ret void
  }
  
  declare void @XXX()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124159



More information about the cfe-commits mailing list