1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -loop-unroll -unroll-threshold=300 -S %s | FileCheck %s 3 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. 9 10target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128" 11target triple = "aarch64-w64-windows-gnu" 12 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 14 15declare i32 @llvm.ctlz.i32(i32, i1 immarg) 16declare double @llvm.log2.f64(double) 17 18define i32 @tripcount_11() { 19; CHECK-LABEL: @tripcount_11( 20; CHECK-NEXT: do.body6.preheader: 21; CHECK-NEXT: br label [[DO_BODY6:%.*]] 22; CHECK: for.cond: 23; CHECK-NEXT: br i1 true, label [[FOR_COND_1:%.*]], label [[IF_THEN11:%.*]] 24; CHECK: do.body6: 25; CHECK-NEXT: br i1 true, label [[FOR_COND:%.*]], label [[IF_THEN11]] 26; CHECK: if.then11: 27; CHECK-NEXT: unreachable 28; CHECK: for.cond.1: 29; CHECK-NEXT: br i1 true, label [[FOR_COND_2:%.*]], label [[IF_THEN11]] 30; CHECK: for.cond.2: 31; CHECK-NEXT: br i1 true, label [[FOR_COND_3:%.*]], label [[IF_THEN11]] 32; CHECK: for.cond.3: 33; CHECK-NEXT: br i1 true, label [[FOR_COND_4:%.*]], label [[IF_THEN11]] 34; CHECK: for.cond.4: 35; CHECK-NEXT: br i1 true, label [[FOR_COND_5:%.*]], label [[IF_THEN11]] 36; CHECK: for.cond.5: 37; CHECK-NEXT: br i1 true, label [[FOR_COND_6:%.*]], label [[IF_THEN11]] 38; CHECK: for.cond.6: 39; CHECK-NEXT: br i1 true, label [[FOR_COND_7:%.*]], label [[IF_THEN11]] 40; CHECK: for.cond.7: 41; CHECK-NEXT: br i1 true, label [[FOR_COND_8:%.*]], label [[IF_THEN11]] 42; CHECK: for.cond.8: 43; CHECK-NEXT: br i1 true, label [[FOR_COND_9:%.*]], label [[IF_THEN11]] 44; CHECK: for.cond.9: 45; CHECK-NEXT: br i1 true, label [[FOR_COND_10:%.*]], label [[IF_THEN11]] 46; CHECK: for.cond.10: 47; CHECK-NEXT: ret i32 0 48; 49do.body6.preheader: 50 br label %do.body6 51 52for.cond: 53 %cmp5.not = icmp eq i32 %div20, 0 54 br i1 %cmp5.not, label %for.end, label %do.body6 55 56do.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 86 %add = or i32 %mul, 4 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 90 91if.then11: 92 unreachable 93 94for.end: 95 ret i32 0 96} 97