-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SimplifyCFG] Pre-commit test for extending HoistThenElseCodeToIf.
Pre-commit test for D155711. Differential Revision: https://reviews.llvm.org/D156617
- Loading branch information
Showing
4 changed files
with
528 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
llvm/test/Transforms/SimplifyCFG/hoist-common-code-with-unreachable.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt < %s -passes='simplifycfg<hoist-common-insts;no-sink-common-insts>' -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s | ||
|
||
define i1 @common_instr_with_unreachable(i64 %a, i64 %b, i64 %c) { | ||
; CHECK-LABEL: @common_instr_with_unreachable( | ||
; CHECK-NEXT: start: | ||
; CHECK-NEXT: switch i64 [[A:%.*]], label [[UNREACHABLE:%.*]] [ | ||
; CHECK-NEXT: i64 0, label [[BB0:%.*]] | ||
; CHECK-NEXT: i64 1, label [[BB1:%.*]] | ||
; CHECK-NEXT: i64 2, label [[BB2:%.*]] | ||
; CHECK-NEXT: ] | ||
; CHECK: unreachable: | ||
; CHECK-NEXT: unreachable | ||
; CHECK: bb0: | ||
; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i64 [[B:%.*]], [[C:%.*]] | ||
; CHECK-NEXT: br label [[EXIT:%.*]] | ||
; CHECK: bb1: | ||
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[B]], [[C]] | ||
; CHECK-NEXT: br label [[EXIT]] | ||
; CHECK: bb2: | ||
; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[B]], [[C]] | ||
; CHECK-NEXT: br label [[EXIT]] | ||
; CHECK: exit: | ||
; CHECK-NEXT: [[RESULT:%.*]] = phi i1 [ [[TMP0]], [[BB0]] ], [ [[TMP1]], [[BB1]] ], [ [[TMP2]], [[BB2]] ] | ||
; CHECK-NEXT: ret i1 [[RESULT]] | ||
; | ||
start: | ||
switch i64 %a, label %unreachable [ | ||
i64 0, label %bb0 | ||
i64 1, label %bb1 | ||
i64 2, label %bb2 | ||
] | ||
|
||
unreachable: | ||
unreachable | ||
|
||
bb0: ; preds = %start | ||
%0 = icmp eq i64 %b, %c | ||
br label %exit | ||
|
||
bb1: ; preds = %start | ||
%1 = icmp eq i64 %b, %c | ||
br label %exit | ||
|
||
bb2: ; preds = %start | ||
%2 = icmp eq i64 %b, %c | ||
br label %exit | ||
|
||
exit: ; preds = %bb2, %bb1, %bb0 | ||
%result = phi i1 [ %0, %bb0 ], [ %1, %bb1 ], [ %2, %bb2 ] | ||
ret i1 %result | ||
} | ||
|
||
define i1 @common_instr_with_unreachable_2(i64 %a, i64 %b, i64 %c) { | ||
; CHECK-LABEL: @common_instr_with_unreachable_2( | ||
; CHECK-NEXT: start: | ||
; CHECK-NEXT: switch i64 [[A:%.*]], label [[BB1:%.*]] [ | ||
; CHECK-NEXT: i64 0, label [[BB0:%.*]] | ||
; CHECK-NEXT: i64 2, label [[BB2:%.*]] | ||
; CHECK-NEXT: ] | ||
; CHECK: bb0: | ||
; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i64 [[B:%.*]], [[C:%.*]] | ||
; CHECK-NEXT: br label [[EXIT:%.*]] | ||
; CHECK: bb1: | ||
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[B]], [[C]] | ||
; CHECK-NEXT: br label [[EXIT]] | ||
; CHECK: bb2: | ||
; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[B]], [[C]] | ||
; CHECK-NEXT: br label [[EXIT]] | ||
; CHECK: exit: | ||
; CHECK-NEXT: [[RESULT:%.*]] = phi i1 [ [[TMP0]], [[BB0]] ], [ [[TMP1]], [[BB1]] ], [ [[TMP2]], [[BB2]] ] | ||
; CHECK-NEXT: ret i1 [[RESULT]] | ||
; | ||
start: | ||
switch i64 %a, label %bb1 [ | ||
i64 0, label %bb0 | ||
i64 1, label %unreachable | ||
i64 2, label %bb2 | ||
] | ||
|
||
unreachable: | ||
unreachable | ||
|
||
bb0: ; preds = %start | ||
%0 = icmp eq i64 %b, %c | ||
br label %exit | ||
|
||
bb1: ; preds = %start | ||
%1 = icmp eq i64 %b, %c | ||
br label %exit | ||
|
||
bb2: ; preds = %start | ||
%2 = icmp eq i64 %b, %c | ||
br label %exit | ||
|
||
exit: ; preds = %bb2, %bb1, %bb0 | ||
%result = phi i1 [ %0, %bb0 ], [ %1, %bb1 ], [ %2, %bb2 ] | ||
ret i1 %result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.