[llvm] ead294b - [NFC][SimplifyCFG] Add test from https://github.com/llvm/llvm-project/issues/53861
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 25 06:12:32 PDT 2022
Author: Roman Lebedev
Date: 2022-03-25T16:12:17+03:00
New Revision: ead294b74c4ba378f9eaf21f5f34bb42d93458ea
URL: https://github.com/llvm/llvm-project/commit/ead294b74c4ba378f9eaf21f5f34bb42d93458ea
DIFF: https://github.com/llvm/llvm-project/commit/ead294b74c4ba378f9eaf21f5f34bb42d93458ea.diff
LOG: [NFC][SimplifyCFG] Add test from https://github.com/llvm/llvm-project/issues/53861
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 0b388e7866116..a3ba53e8bf531 100644
--- a/llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll
+++ b/llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll
@@ -1063,4 +1063,64 @@ exit:
ret i32 %r
}
+; https://github.com/llvm/llvm-project/issues/53861
+define i32 @firewall(i8* %data) {
+; CHECK-LABEL: @firewall(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[I:%.*]] = load i8, i8* [[DATA:%.*]], align 1
+; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, i8* [[DATA]], i64 64
+; CHECK-NEXT: [[I1:%.*]] = bitcast i8* [[ADD_PTR]] to i16*
+; CHECK-NEXT: [[I2:%.*]] = load i16, i16* [[I1]], align 2
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[I]], 17
+; CHECK-NEXT: [[CMP3:%.*]] = icmp eq i16 [[I2]], 1
+; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[CMP]], i1 [[CMP3]], i1 false
+; CHECK-NEXT: br i1 [[OR_COND]], label [[CLEANUP:%.*]], label [[IF_END:%.*]]
+; CHECK: if.end:
+; CHECK-NEXT: [[CMP10:%.*]] = icmp eq i16 [[I2]], 2
+; CHECK-NEXT: [[OR_COND33:%.*]] = select i1 [[CMP]], i1 [[CMP10]], i1 false
+; CHECK-NEXT: br i1 [[OR_COND33]], label [[CLEANUP]], label [[IF_END13:%.*]]
+; CHECK: if.end13:
+; CHECK-NEXT: [[CMP19:%.*]] = icmp eq i16 [[I2]], 3
+; CHECK-NEXT: [[OR_COND34:%.*]] = select i1 [[CMP]], i1 [[CMP19]], i1 false
+; CHECK-NEXT: br i1 [[OR_COND34]], label [[CLEANUP]], label [[IF_END22:%.*]]
+; CHECK: if.end22:
+; CHECK-NEXT: [[CMP28:%.*]] = icmp eq i16 [[I2]], 4
+; CHECK-NEXT: [[OR_COND35:%.*]] = select i1 [[CMP]], i1 [[CMP28]], i1 false
+; CHECK-NEXT: [[DOT:%.*]] = zext i1 [[OR_COND35]] to i32
+; CHECK-NEXT: br label [[CLEANUP]]
+; CHECK: cleanup:
+; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ 1, [[IF_END]] ], [ 1, [[IF_END13]] ], [ [[DOT]], [[IF_END22]] ]
+; CHECK-NEXT: ret i32 [[RETVAL_0]]
+;
+entry:
+ %i = load i8, i8* %data, align 1
+ %add.ptr = getelementptr inbounds i8, i8* %data, i64 64
+ %i1 = bitcast i8* %add.ptr to i16*
+ %i2 = load i16, i16* %i1, align 2
+ %cmp = icmp eq i8 %i, 17
+ %cmp3 = icmp eq i16 %i2, 1
+ %or.cond = select i1 %cmp, i1 %cmp3, i1 false
+ br i1 %or.cond, label %cleanup, label %if.end
+
+if.end:
+ %cmp10 = icmp eq i16 %i2, 2
+ %or.cond33 = select i1 %cmp, i1 %cmp10, i1 false
+ br i1 %or.cond33, label %cleanup, label %if.end13
+
+if.end13:
+ %cmp19 = icmp eq i16 %i2, 3
+ %or.cond34 = select i1 %cmp, i1 %cmp19, i1 false
+ br i1 %or.cond34, label %cleanup, label %if.end22
+
+if.end22:
+ %cmp28 = icmp eq i16 %i2, 4
+ %or.cond35 = select i1 %cmp, i1 %cmp28, i1 false
+ %. = zext i1 %or.cond35 to i32
+ br label %cleanup
+
+cleanup:
+ %retval.0 = phi i32 [ 1, %entry ], [ 1, %if.end ], [ 1, %if.end13 ], [ %., %if.end22 ]
+ ret i32 %retval.0
+}
+
attributes #0 = { nounwind argmemonly speculatable }
More information about the llvm-commits
mailing list