Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SimplifyCFG] Teach SimplifyCondBranchToTwoReturns() to preserve DomT…
…ree, part 1 ... for the general case of returning a value.
- Loading branch information
Showing
4 changed files
with
28 additions
and
2 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
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
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
21 changes: 21 additions & 0 deletions
21
llvm/test/Transforms/SimplifyCFG/merge-duplicate-conditional-ret-val.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,21 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -simplifycfg-dup-ret -S | FileCheck %s | ||
|
||
declare void @bar() | ||
declare void @baz() | ||
|
||
define i8 @foo(i1 %c, i8 %v0, i8 %v1) { | ||
; CHECK-LABEL: @foo( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[C:%.*]], i8 [[V0:%.*]], i8 [[V1:%.*]] | ||
; CHECK-NEXT: ret i8 [[SPEC_SELECT]] | ||
; | ||
entry: | ||
br i1 %c, label %true, label %false | ||
|
||
true: | ||
ret i8 %v0 | ||
|
||
false: | ||
ret i8 %v1 | ||
} |