xref: /llvm-project/llvm/test/Transforms/SCCP/calltest.ll (revision 106ed59fe962e0443d2f59a81fa6f52875ced5c0)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=sccp,loop-deletion,simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
3
4declare double @sqrt(double) readnone nounwind willreturn
5%empty = type {}
6declare %empty @has_side_effects()
7
8; No matter how hard you try, sqrt(1.0) is always 1.0.  This allows the
9; optimizer to delete this loop.
10define double @test_0(i32 %param) {
11; CHECK-LABEL: @test_0(
12; CHECK-NEXT:  entry:
13; CHECK-NEXT:    ret double 1.000000e+00
14;
15entry:
16  br label %Loop
17Loop:		; preds = %Loop, %entry
18  %I2 = phi i32 [ 0, %entry ], [ %I3, %Loop ]
19  %V = phi double [ 1.000000e+00, %entry ], [ %V2, %Loop ]
20  %V2 = call double @sqrt( double %V )
21  %I3 = add i32 %I2, 1
22  %tmp.7 = icmp ne i32 %I3, %param
23  br i1 %tmp.7, label %Loop, label %Exit
24Exit:		; preds = %Loop
25  ret double %V
26}
27
28define i32 @test_1() {
29; CHECK-LABEL: @test_1(
30; CHECK-NEXT:    [[TMP1:%.*]] = call [[EMPTY:%.*]] @has_side_effects()
31; CHECK-NEXT:    ret i32 0
32;
33  %1 = call %empty @has_side_effects()
34  ret i32 0
35}
36
37define i32 @test_not_willreturn() {
38; CHECK-LABEL: @test_not_willreturn(
39; CHECK-NEXT:    [[TMP1:%.*]] = call [[EMPTY:%.*]] @has_side_effects() #[[ATTR1:[0-9]+]]
40; CHECK-NEXT:    ret i32 0
41;
42  %1 = call %empty @has_side_effects() nounwind readonly
43  ret i32 0
44}
45