1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -loop-unroll -unroll-threshold=300 -S %s | FileCheck %s
4 ; This test was full unrolled and simplified at -O3 with clang 11.
5 ; Changes to the cost model may cause that decision to differ.
6 ; We would not necessarily view the difference as a regression,
7 ; but we should be aware that cost model changes can affect an
8 ; example like this drastically.
10 target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128"
11 target triple = "aarch64-w64-windows-gnu"
13 @tab_log2 = internal unnamed_addr constant [33 x i16] [i16 4, i16 1459, i16 2870, i16 4240, i16 5572, i16 6867, i16 8127, i16 9355, i16 10552, i16 11719, i16 12858, i16 13971, i16 15057, i16 16120, i16 17158, i16 18175, i16 19170, i16 20145, i16 21100, i16 22036, i16 22954, i16 23854, i16 24738, i16 25605, i16 26457, i16 27294, i16 28116, i16 28924, i16 29719, i16 30500, i16 31269, i16 32025, i16 -32767], align 2
15 declare i32 @llvm.ctlz.i32(i32, i1 immarg)
16 declare double @llvm.log2.f64(double)
18 define i32 @tripcount_11() {
19 ; CHECK-LABEL: @tripcount_11(
20 ; CHECK-NEXT: do.body6.preheader:
21 ; CHECK-NEXT: br label [[DO_BODY6:%.*]]
23 ; CHECK-NEXT: br i1 true, label [[FOR_COND_1:%.*]], label [[IF_THEN11:%.*]]
25 ; CHECK-NEXT: br i1 true, label [[FOR_COND_2:%.*]], label [[IF_THEN11]]
27 ; CHECK-NEXT: br i1 true, label [[FOR_COND_3:%.*]], label [[IF_THEN11]]
29 ; CHECK-NEXT: br i1 true, label [[FOR_COND_4:%.*]], label [[IF_THEN11]]
31 ; CHECK-NEXT: br i1 true, label [[FOR_COND_5:%.*]], label [[IF_THEN11]]
33 ; CHECK-NEXT: br i1 true, label [[FOR_COND_6:%.*]], label [[IF_THEN11]]
35 ; CHECK-NEXT: br i1 true, label [[FOR_COND_7:%.*]], label [[IF_THEN11]]
37 ; CHECK-NEXT: br i1 true, label [[FOR_COND_8:%.*]], label [[IF_THEN11]]
39 ; CHECK-NEXT: br i1 true, label [[FOR_COND_9:%.*]], label [[IF_THEN11]]
41 ; CHECK-NEXT: br i1 true, label [[FOR_COND_10:%.*]], label [[IF_THEN11]]
43 ; CHECK-NEXT: ret i32 0
45 ; CHECK-NEXT: br i1 true, label [[FOR_COND:%.*]], label [[IF_THEN11]]
47 ; CHECK-NEXT: unreachable
53 %cmp5.not = icmp eq i32 %div20, 0
54 br i1 %cmp5.not, label %for.end, label %do.body6
57 %i.021 = phi i32 [ %div20, %for.cond ], [ 1024, %do.body6.preheader ]
58 %or.i = or i32 %i.021, 1
59 %t0 = tail call i32 @llvm.ctlz.i32(i32 %or.i, i1 true)
60 %shl.i = shl i32 %i.021, %t0
61 %and.i = lshr i32 %shl.i, 26
62 %t1 = trunc i32 %and.i to i8
63 %conv3.i = and i8 %t1, 31
64 %and4.i = lshr i32 %shl.i, 11
65 %conv6.i = and i32 %and4.i, 32767
66 %idxprom.i = zext i8 %conv3.i to i64
67 %arrayidx.i7 = getelementptr inbounds [33 x i16], [33 x i16]* @tab_log2, i64 0, i64 %idxprom.i
68 %t2 = load i16, i16* %arrayidx.i7, align 2
69 %conv7.i = zext i16 %t2 to i32
70 %narrow.i = add nuw nsw i8 %conv3.i, 1
71 %t3 = zext i8 %narrow.i to i64
72 %arrayidx11.i = getelementptr inbounds [33 x i16], [33 x i16]* @tab_log2, i64 0, i64 %t3
73 %t4 = load i16, i16* %arrayidx11.i, align 2
74 %conv12.i = zext i16 %t4 to i32
75 %sub16.i = sub nsw i32 %conv12.i, %conv7.i
76 %mul.i8 = mul nsw i32 %conv6.i, %sub16.i
77 %shr17.i = ashr i32 %mul.i8, 15
78 %conv.i = shl nuw nsw i32 %t0, 15
79 %shl20.i = xor i32 %conv.i, 1015808
80 %add18.i = add nuw nsw i32 %shl20.i, %conv7.i
81 %add21.i = add nsw i32 %add18.i, %shr17.i
82 %conv = sitofp i32 %i.021 to double
83 %t5 = tail call double @llvm.log2.f64(double %conv)
84 %conv8 = fptosi double %t5 to i32
85 %mul = shl nsw i32 %conv8, 15
87 %cmp9 = icmp eq i32 %add21.i, %add
88 %div20 = lshr i32 %i.021, 1
89 br i1 %cmp9, label %for.cond, label %if.then11