[llvm-branch-commits] [llvm] effbbde - [NFC][SimplifyCFG] Add another miscompiled test for PR48450

Roman Lebedev via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Dec 14 09:19:46 PST 2020


Author: Roman Lebedev
Date: 2020-12-14T20:14:31+03:00
New Revision: effbbdec6e954798b8ae6a5f3c5cd45995a0a2eb

URL: https://github.com/llvm/llvm-project/commit/effbbdec6e954798b8ae6a5f3c5cd45995a0a2eb
DIFF: https://github.com/llvm/llvm-project/commit/effbbdec6e954798b8ae6a5f3c5cd45995a0a2eb.diff

LOG: [NFC][SimplifyCFG] Add another miscompiled test for PR48450

Added: 
    

Modified: 
    llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll b/llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll
index 521ffa89854d..557f47ee4dcf 100644
--- a/llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll
+++ b/llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll
@@ -779,3 +779,66 @@ for.bodythread-pre-split:
 if.end.loopexit:
   ret void
 }
+
+define void @pr48450_2(i1 %enable_loopback) {
+; CHECK-LABEL: @pr48450_2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
+; CHECK:       for.body:
+; CHECK-NEXT:    [[COUNTDOWN:%.*]] = phi i16 [ 128, [[ENTRY:%.*]] ], [ [[DEC2:%.*]], [[FOR_BODYTHREAD_PRE_SPLIT:%.*]] ]
+; CHECK-NEXT:    [[C:%.*]] = call i1 @gen1()
+; CHECK-NEXT:    br i1 [[C]], label [[FOR_INC:%.*]], label [[IF_THEN:%.*]]
+; CHECK:       for.inc:
+; CHECK-NEXT:    [[DOTOLD:%.*]] = add i16 [[COUNTDOWN]], -1
+; CHECK-NEXT:    [[DOTOLD3:%.*]] = icmp eq i16 [[COUNTDOWN]], 0
+; CHECK-NEXT:    br i1 [[DOTOLD3]], label [[IF_END_LOOPEXIT:%.*]], label [[FOR_BODYTHREAD_PRE_SPLIT]]
+; CHECK:       if.then:
+; CHECK-NEXT:    [[C2:%.*]] = call i1 @gen1()
+; CHECK-NEXT:    [[C2_NOT:%.*]] = xor i1 [[C2]], true
+; CHECK-NEXT:    [[DEC:%.*]] = add i16 [[COUNTDOWN]], -1
+; CHECK-NEXT:    [[CMP_NOT:%.*]] = icmp eq i16 [[COUNTDOWN]], 0
+; CHECK-NEXT:    [[OR_COND:%.*]] = or i1 [[C2_NOT]], [[CMP_NOT]]
+; CHECK-NEXT:    br i1 [[OR_COND]], label [[IF_END_LOOPEXIT]], label [[FOR_BODYTHREAD_PRE_SPLIT]]
+; CHECK:       for.bodythread-pre-split:
+; CHECK-NEXT:    [[DEC2]] = phi i16 [ undef, [[FOR_BODYTHREAD_PRE_SPLIT_LOOPBACK:%.*]] ], [ [[DOTOLD]], [[FOR_INC]] ], [ [[DEC]], [[IF_THEN]] ]
+; CHECK-NEXT:    [[SHOULD_LOOPBACK:%.*]] = phi i1 [ true, [[FOR_INC]] ], [ false, [[FOR_BODYTHREAD_PRE_SPLIT_LOOPBACK]] ], [ true, [[IF_THEN]] ]
+; CHECK-NEXT:    [[DO_LOOPBACK:%.*]] = and i1 [[SHOULD_LOOPBACK]], [[ENABLE_LOOPBACK:%.*]]
+; CHECK-NEXT:    call void @sideeffect0()
+; CHECK-NEXT:    br i1 [[DO_LOOPBACK]], label [[FOR_BODYTHREAD_PRE_SPLIT_LOOPBACK]], label [[FOR_BODY]]
+; CHECK:       for.bodythread-pre-split.loopback:
+; CHECK-NEXT:    call void @sideeffect0()
+; CHECK-NEXT:    br label [[FOR_BODYTHREAD_PRE_SPLIT]]
+; CHECK:       if.end.loopexit:
+; CHECK-NEXT:    [[DEC1:%.*]] = phi i16 [ undef, [[IF_THEN]] ], [ [[DOTOLD]], [[FOR_INC]] ]
+; CHECK-NEXT:    ret void
+;
+entry:
+  br label %for.body
+
+for.body:
+  %countdown = phi i16 [ 128, %entry ], [ %dec, %for.bodythread-pre-split ]
+  %c = call i1 @gen1()
+  br i1 %c, label %for.inc, label %if.then
+
+for.inc:
+  %dec = add i16 %countdown, -1
+  %cmp.not = icmp eq i16 %countdown, 0
+  br i1 %cmp.not, label %if.end.loopexit, label %for.bodythread-pre-split
+
+if.then:
+  %c2 = call i1 @gen1()
+  br i1 %c2, label %for.inc, label %if.end.loopexit
+
+for.bodythread-pre-split:
+  %should_loopback = phi i1 [ 1, %for.inc ], [ 0, %for.bodythread-pre-split.loopback ]
+  %do_loopback = and i1 %should_loopback, %enable_loopback
+  call void @sideeffect0()
+  br i1 %do_loopback, label %for.bodythread-pre-split.loopback, label %for.body
+
+for.bodythread-pre-split.loopback:
+  call void @sideeffect0()
+  br label %for.bodythread-pre-split
+
+if.end.loopexit:
+  ret void
+}


        


More information about the llvm-branch-commits mailing list