brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 35115cf Raw
52 lines · plain
1; RUN: opt < %s -loop-unroll -codegenprepare -S -mtriple=x86_64 | FileCheck %s2 3; This test is a worst-case scenario for bitreversal/byteswap detection.4; After loop unrolling (the unrolled loop is unreadably large so it has been kept5; rolled here), we have a binary tree of OR operands (as bitreversal detection6; looks straight through shifts):7;8;  OR9;  | \10;  |  LSHR11;  | /12;  OR13;  | \14;  |  LSHR15;  | /16;  OR17;18; This results in exponential runtime. The loop here is 32 iterations which will19; totally hang if we don't deal with this case cleverly.20 21@b = common global i32 0, align 422 23; CHECK: define i32 @fn124define i32 @fn1() {25entry:26  %b.promoted = load i32, ptr @b, align 4, !tbaa !227  br label %for.body28 29for.body:                                         ; preds = %for.body, %entry30  %or4 = phi i32 [ %b.promoted, %entry ], [ %or, %for.body ]31  %i.03 = phi i32 [ 0, %entry ], [ %inc, %for.body ]32  %shr = lshr i32 %or4, 133  %or = or i32 %shr, %or434  %inc = add nuw nsw i32 %i.03, 135  %exitcond = icmp eq i32 %inc, 3236  br i1 %exitcond, label %for.end, label %for.body37 38for.end:                                          ; preds = %for.body39  store i32 %or, ptr @b, align 4, !tbaa !240  ret i32 undef41}42 43!llvm.module.flags = !{!0}44!llvm.ident = !{!1}45 46!0 = !{i32 1, !"PIC Level", i32 2}47!1 = !{!"clang version 3.8.0"}48!2 = !{!3, !3, i64 0}49!3 = !{!"int", !4, i64 0}50!4 = !{!"omnipotent char", !5, i64 0}51!5 = !{!"Simple C/C++ TBAA"}52