xref: /llvm-project/llvm/test/Transforms/LoopUnroll/X86/call-remark.ll (revision 02e4186d0b3508e79d78b0ec844518b13a3fe9ea)
1; RUN: opt -passes=debugify,loop-unroll -mcpu=znver3 -pass-remarks=loop-unroll -pass-remarks-analysis=loop-unroll < %s -S 2>&1 | FileCheck --check-prefixes=ALL,UNROLL %s
2; RUN: opt -passes=debugify,loop-unroll -mcpu=znver3 -pass-remarks=TTI -pass-remarks-analysis=TTI  < %s -S 2>&1 | FileCheck --check-prefixes=ALL,TTI %s
3; RUN: opt -passes=debugify,loop-unroll -mcpu=znver4 -pass-remarks=loop-unroll -pass-remarks-analysis=loop-unroll < %s -S 2>&1 | FileCheck --check-prefixes=ALL,UNROLL %s
4; RUN: opt -passes=debugify,loop-unroll -mcpu=znver5 -pass-remarks=loop-unroll -pass-remarks-analysis=loop-unroll < %s -S 2>&1 | FileCheck --check-prefixes=ALL,UNROLL %s
5
6; RUN: opt -passes=debugify,loop-unroll -mcpu=znver3 -pass-remarks=loop-unroll -pass-remarks-analysis=loop-unroll < %s -S 2>&1 --try-experimental-debuginfo-iterators | FileCheck --check-prefixes=ALL,UNROLL %s
7
8target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
9target triple = "x86_64-unknown-linux-gnu"
10
11; TTI: remark: <stdin>:7:1: advising against unrolling the loop because it contains a call
12; UNROLL: remark: <stdin>:14:1: unrolled loop by a factor of 8 with run-time trip count
13
14define void @contains_external_call(i32 %count) {
15; ALL-LABEL: @contains_external_call(
16; ALL-NOT: unroll
17entry:
18  %cmp.not3 = icmp eq i32 %count, 0
19  br i1 %cmp.not3, label %for.cond.cleanup, label %for.body
20
21for.body:
22  %i.04 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
23  tail call void @sideeffect()
24  %inc = add nuw nsw i32 %i.04, 1
25  %cmp.not = icmp eq i32 %inc, %count
26  br i1 %cmp.not, label %for.cond.cleanup, label %for.body
27
28for.cond.cleanup:
29  ret void
30}
31
32declare void @sideeffect()
33
34define i32 @no_external_calls(i32 %count) {
35; ALL-LABEL: @no_external_calls(
36; ALL: unroll
37entry:
38  %cmp.not5 = icmp eq i32 %count, 0
39  br i1 %cmp.not5, label %for.end, label %for.body
40
41for.body:
42  %i.06 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
43  %inc = add nuw nsw i32 %i.06, 1
44  %cmp.not = icmp eq i32 %inc, %count
45  br i1 %cmp.not, label %for.end, label %for.body
46
47for.end:
48  ret i32 %count
49}
50