brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · fc38110 Raw
40 lines · plain
1; RUN: opt < %s -S -passes=loop-unroll -unroll-max-iteration-count-to-analyze=100 -unroll-threshold=12 -unroll-max-percent-threshold-boost=400 | FileCheck %s2; RUN: opt < %s -S -passes='require<opt-remark-emit>,loop(loop-unroll-full)' -unroll-max-iteration-count-to-analyze=100 -unroll-threshold=12 -unroll-max-percent-threshold-boost=400 | FileCheck %s3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"4 5@known_constant = internal unnamed_addr constant [10 x i32] [i32 0, i32 0, i32 0, i32 0, i32 1, i32 0, i32 0, i32 0, i32 0, i32 0], align 166 7; If a load becomes a constant after loop unrolling, we sometimes can simplify8; CFG. This test verifies that we handle such cases.9; After one operand in an instruction is constant-folded and the10; instruction is simplified, the other operand might become dead.11; In this test we have::12; for i in 1..10:13;   r += Aptr B[i]14; A[i] is 0 almost at every iteration, so there is no need in loading B[i] at15; all.16 17 18; CHECK-LABEL: @unroll_dce19; CHECK-NOT:   br i1 %exitcond, label %for.end, label %for.body20define i32 @unroll_dce(ptr noalias nocapture readonly %b) {21entry:22  br label %for.body23 24for.body:                                         ; preds = %for.body, %entry25  %iv.0 = phi i64 [ 0, %entry ], [ %iv.1, %for.body ]26  %r.0 = phi i32 [ 0, %entry ], [ %r.1, %for.body ]27  %arrayidx1 = getelementptr inbounds [10 x i32], ptr @known_constant, i64 0, i64 %iv.028  %x1 = load i32, ptr %arrayidx1, align 429  %arrayidx2 = getelementptr inbounds i32, ptr %b, i64 %iv.030  %x2 = load i32, ptr %arrayidx2, align 431  %mul = mul i32 %x1, %x232  %r.1 = add i32 %mul, %r.033  %iv.1 = add nuw nsw i64 %iv.0, 134  %exitcond = icmp eq i64 %iv.1, 1035  br i1 %exitcond, label %for.end, label %for.body36 37for.end:                                          ; preds = %for.body38  ret i32 %r.139}40