brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · b473e26 Raw
95 lines · plain
1; RUN: opt %loadNPMPolly '-passes=polly-custom<ast>' -polly-print-ast -disable-output < %s | FileCheck %s2 3;#define N 204;#include "limits.h"5;#include <stdio.h>6;int A[2 * N];7;8;void single_do_loop_scev_replace() {9;  int i;10;11;  __sync_synchronize();12;13;  i = 0;14;15;  do {16;    A[2 * i] = i;17;    ++i;18;  } while (i < N);19;20;  __sync_synchronize();21;}22;23;int main () {24;  int i;25;26;  single_do_loop_scev_replace();27;28;  fprintf(stdout, "Output %d\n", A[0]);29;30;  if (A[2 * N - 2] == N - 1)31;    return 0;32;  else33;    return 1;34;}35 36target 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"37 38%struct._IO_FILE = type { i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i64, i16, i8, [1 x i8], ptr, i64, ptr, ptr, ptr, ptr, i64, i32, [20 x i8] }39%struct._IO_marker = type { ptr, ptr, i32 }40 41@A = common global [40 x i32] zeroinitializer, align 4 ; <ptr> [#uses=3]42@stdout = external global ptr       ; <ptr> [#uses=1]43@.str = private constant [11 x i8] c"Output %d\0A\00" ; <ptr> [#uses=1]44 45define void @single_do_loop_scev_replace() nounwind {46entry:47  fence seq_cst48  br label %do.body49 50do.body:                                          ; preds = %do.cond, %entry51  %indvar = phi i64 [ %indvar.next, %do.cond ], [ 0, %entry ] ; <i64> [#uses=3]52  %tmp = mul i64 %indvar, 2                       ; <i64> [#uses=1]53  %arrayidx = getelementptr [40 x i32], ptr @A, i64 0, i64 %tmp ; <ptr> [#uses=1]54  %i.0 = trunc i64 %indvar to i32                 ; <i32> [#uses=1]55  br label %do.cond56 57do.cond:                                          ; preds = %do.body58  store i32 %i.0, ptr %arrayidx59  %indvar.next = add i64 %indvar, 1               ; <i64> [#uses=2]60  %exitcond = icmp ne i64 %indvar.next, 20        ; <i1> [#uses=1]61  br i1 %exitcond, label %do.body, label %do.end62 63do.end:                                           ; preds = %do.cond64  fence seq_cst65  ret void66}67 68define i32 @main() nounwind {69entry:70  call void @single_do_loop_scev_replace()71  %tmp = load ptr, ptr @stdout          ; <ptr> [#uses=1]72  %tmp1 = load i32, ptr @A ; <i32> [#uses=1]73  %call = call i32 (ptr, ptr, ...) @fprintf(ptr %tmp, ptr @.str, i32 %tmp1) ; <i32> [#uses=0]74  %tmp2 = load i32, ptr getelementptr inbounds ([40 x i32], ptr @A, i32 0, i64 38) ; <i32> [#uses=1]75  %cmp = icmp eq i32 %tmp2, 19                    ; <i1> [#uses=1]76  br i1 %cmp, label %if.then, label %if.else77 78if.then:                                          ; preds = %entry79  br label %return80 81if.else:                                          ; preds = %entry82  br label %return83 84return:                                           ; preds = %if.else, %if.then85  %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.else ] ; <i32> [#uses=1]86  ret i32 %retval.087}88 89declare i32 @fprintf(ptr, ptr, ...)90 91; CHECK: for (int c0 = 0; c0 <= 19; c0 += 1)92; CHECK:   Stmt_do_cond(c0);93 94 95