diff options
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/IPConstantProp/musttail-call.ll | 4 | ||||
| -rw-r--r-- | llvm/test/Transforms/SCCP/ipsccp-predicated.ll | 68 |
2 files changed, 70 insertions, 2 deletions
diff --git a/llvm/test/Transforms/IPConstantProp/musttail-call.ll b/llvm/test/Transforms/IPConstantProp/musttail-call.ll index 75877585710..567ca408099 100644 --- a/llvm/test/Transforms/IPConstantProp/musttail-call.ll +++ b/llvm/test/Transforms/IPConstantProp/musttail-call.ll @@ -9,7 +9,7 @@ define i8* @start(i8 %v) { %c1 = icmp eq i8 %v, 0 br i1 %c1, label %true, label %false true: - ; CHECK: %ca = musttail call i8* @side_effects(i8 %v) + ; CHECK: %ca = musttail call i8* @side_effects(i8 0) ; CHECK: ret i8* %ca %ca = musttail call i8* @side_effects(i8 %v) ret i8* %ca @@ -34,7 +34,7 @@ define internal i8* @side_effects(i8 %v) { ; is always `null`. ; The call can't be removed due to `external` call above, though. - ; CHECK: %ca = musttail call i8* @start(i8 %v) + ; CHECK: %ca = musttail call i8* @start(i8 0) %ca = musttail call i8* @start(i8 %v) ; Thus the result must be returned anyway diff --git a/llvm/test/Transforms/SCCP/ipsccp-predicated.ll b/llvm/test/Transforms/SCCP/ipsccp-predicated.ll new file mode 100644 index 00000000000..531fbba8f70 --- /dev/null +++ b/llvm/test/Transforms/SCCP/ipsccp-predicated.ll @@ -0,0 +1,68 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -ipsccp -S | FileCheck %s + +define i32 @test1(i32 %v) { +; CHECK-LABEL: @test1( +; CHECK-NEXT: Entry: +; CHECK-NEXT: [[TOBOOL1:%.*]] = icmp eq i32 [[V:%.*]], 10 +; CHECK-NEXT: br i1 [[TOBOOL1]], label [[T:%.*]], label [[F:%.*]] +; CHECK: T: +; CHECK-NEXT: [[R:%.*]] = call i32 @callee(i32 20) +; CHECK-NEXT: ret i32 [[R]] +; CHECK: F: +; CHECK-NEXT: [[X:%.*]] = call i32 @callee(i32 [[V]]) +; CHECK-NEXT: ret i32 [[X]] +; +Entry: + %tobool1 = icmp eq i32 %v, 10 + br i1 %tobool1, label %T, label %F + +T: + %a = add i32 %v, 10 + %r = call i32 @callee(i32 %a) + ret i32 %r + +F: + %x = call i32 @callee(i32 %v) + ret i32 %x +} + + +define internal i32 @test2(i32 %v, i32 %c) { +; CHECK-LABEL: @test2( +; CHECK-NEXT: Entry: +; CHECK-NEXT: [[TOBOOL1:%.*]] = icmp eq i32 [[V:%.*]], 99 +; CHECK-NEXT: br i1 [[TOBOOL1]], label [[T:%.*]], label [[F:%.*]] +; CHECK: T: +; CHECK-NEXT: [[R:%.*]] = call i32 @callee(i32 109) +; CHECK-NEXT: ret i32 [[R]] +; CHECK: F: +; CHECK-NEXT: [[X:%.*]] = call i32 @callee(i32 [[V]]) +; CHECK-NEXT: ret i32 [[X]] +; +Entry: + %tobool1 = icmp eq i32 %v, %c + br i1 %tobool1, label %T, label %F + +T: + %a = add i32 %v, 10 + %r = call i32 @callee(i32 %a) + ret i32 %r + +F: + %x = call i32 @callee(i32 %v) + ret i32 %x +} + +define i32 @caller_test2(i32 %v) { +; CHECK-LABEL: @caller_test2( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[R:%.*]] = call i32 @test2(i32 [[V:%.*]], i32 99) +; CHECK-NEXT: ret i32 [[R]] +; +entry: + %r = call i32 @test2(i32 %v, i32 99) + ret i32 %r +} + +declare i32 @callee(i32) |

