reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
; RUN: opt %loadPolly -basicaa -polly-ast -polly-ast-detect-parallel -analyze < %s | FileCheck %s

; Verify that we actually detect this loop as the innermost loop even though
; there is a conditional inside.

; CHECK: #pragma simd
; CHECK: for (int c0 = 0; c0 <= 1023; c0 += 1) {
; CHECK:   if (c0 >= m + 1025) {
; CHECK:     Stmt_if_else(c0);
; CHECK:   } else
; CHECK:     Stmt_if_then(c0);
; CHECK:   Stmt_if_end(c0);
; CHECK: }

target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"

@A = common global [1024 x i32] zeroinitializer, align 16
@B = common global [1024 x i32] zeroinitializer, align 16

define void @loop_with_condition(i32 %m) nounwind {
entry:
  fence seq_cst
  %tmp = sub i32 0, %m
  %tmp1 = zext i32 %tmp to i64
  br label %for.cond

for.cond:                                         ; preds = %for.inc, %entry
  %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
  %arrayidx = getelementptr [1024 x i32], [1024 x i32]* @A, i64 0, i64 %indvar
  %arrayidx10 = getelementptr [1024 x i32], [1024 x i32]* @B, i64 0, i64 %indvar
  %tmp2 = add i64 %tmp1, %indvar
  %sub = trunc i64 %tmp2 to i32
  %exitcond = icmp ne i64 %indvar, 1024
  br i1 %exitcond, label %for.body, label %for.end

for.body:                                         ; preds = %for.cond
  %cmp3 = icmp sle i32 %sub, 1024
  br i1 %cmp3, label %if.then, label %if.else

if.then:                                          ; preds = %for.body
  store i32 1, i32* %arrayidx
  br label %if.end

if.else:                                          ; preds = %for.body
  store i32 2, i32* %arrayidx
  br label %if.end

if.end:                                           ; preds = %if.else, %if.then
  store i32 3, i32* %arrayidx10
  br label %for.inc

for.inc:                                          ; preds = %if.end
  %indvar.next = add i64 %indvar, 1
  br label %for.cond

for.end:                                          ; preds = %for.cond
  fence seq_cst
  ret void
}

define i32 @main() nounwind {
entry:
  call void @llvm.memset.p0i8.i64(i8* bitcast ([1024 x i32]* @A to i8*), i8 0, i64 4096, i32 1, i1 false)
  call void @llvm.memset.p0i8.i64(i8* bitcast ([1024 x i32]* @B to i8*), i8 0, i64 4096, i32 1, i1 false)
  call void @loop_with_condition(i32 5)
  br label %for.cond

for.cond:                                         ; preds = %for.inc, %entry
  %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %entry ]
  %arrayidx = getelementptr [1024 x i32], [1024 x i32]* @B, i64 0, i64 %indvar1
  %i.0 = trunc i64 %indvar1 to i32
  %cmp = icmp slt i32 %i.0, 1024
  br i1 %cmp, label %for.body, label %for.end

for.body:                                         ; preds = %for.cond
  %tmp3 = load i32, i32* %arrayidx
  %cmp4 = icmp ne i32 %tmp3, 3
  br i1 %cmp4, label %if.then, label %if.end

if.then:                                          ; preds = %for.body
  br label %return

if.end:                                           ; preds = %for.body
  br label %for.inc

for.inc:                                          ; preds = %if.end
  %indvar.next2 = add i64 %indvar1, 1
  br label %for.cond

for.end:                                          ; preds = %for.cond
  br label %for.cond6

for.cond6:                                        ; preds = %for.inc12, %for.end
  %indvar = phi i64 [ %indvar.next, %for.inc12 ], [ 0, %for.end ]
  %arrayidx15 = getelementptr [1024 x i32], [1024 x i32]* @A, i64 0, i64 %indvar
  %i.1 = trunc i64 %indvar to i32
  %cmp8 = icmp slt i32 %i.1, 1024
  br i1 %cmp8, label %for.body9, label %for.end35

for.body9:                                        ; preds = %for.cond6
  br i1 true, label %land.lhs.true, label %if.else

land.lhs.true:                                    ; preds = %for.body9
  %tmp16 = load i32, i32* %arrayidx15
  %cmp17 = icmp ne i32 %tmp16, 1
  br i1 %cmp17, label %if.then18, label %if.else

if.then18:                                        ; preds = %land.lhs.true
  br label %return

if.else:                                          ; preds = %land.lhs.true, %for.body9
  br i1 false, label %land.lhs.true23, label %if.end30

land.lhs.true23:                                  ; preds = %if.else
  %tmp27 = load i32, i32* %arrayidx15
  %cmp28 = icmp ne i32 %tmp27, 2
  br i1 %cmp28, label %if.then29, label %if.end30

if.then29:                                        ; preds = %land.lhs.true23
  br label %return

if.end30:                                         ; preds = %land.lhs.true23, %if.else
  br label %if.end31

if.end31:                                         ; preds = %if.end30
  br label %for.inc12

for.inc12:                                        ; preds = %if.end31
  %indvar.next = add i64 %indvar, 1
  br label %for.cond6

for.end35:                                        ; preds = %for.cond6
  br label %return

return:                                           ; preds = %for.end35, %if.then29, %if.then18, %if.then
  %retval.0 = phi i32 [ 1, %if.then ], [ 1, %if.then18 ], [ 1, %if.then29 ], [ 0, %for.end35 ]
  ret i32 %retval.0
}

declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind