1; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s 2; 3; This checks that the no-wraps checks will be computed fast as some example 4; already showed huge slowdowns even though the inbounds and nsw flags were 5; all in place. 6; 7; // Inspired by itrans8x8 in transform8x8.c from the ldecode benchmark. 8; void fast(char *A, char N, char M) { 9; for (char i = 0; i < 8; i++) { 10; short index0 = (short)(i + N); 11; #ifdef fast 12; short index1 = (index0 * 1) + (short)M; 13; #else 14; short index1 = (index0 * 16) + (short)M; 15; #endif 16; A[index1]++; 17; } 18; } 19; 20; CHECK: Function: fast 21; CHECK: Function: slow 22; 23target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 24 25define void @fast(i8* %A, i8 %N, i8 %M) { 26entry: 27 br label %for.cond 28 29for.cond: ; preds = %for.inc, %entry 30 %indvars.iv = phi i8 [ %indvars.iv.next, %for.inc ], [ 0, %entry ] 31 %exitcond = icmp ne i8 %indvars.iv, 8 32 br i1 %exitcond, label %for.body, label %for.end 33 34for.body: ; preds = %for.cond 35 %tmp3 = add nsw i8 %indvars.iv, %N 36 %tmp3ext = sext i8 %tmp3 to i16 37 ;%mul = mul nsw i16 %tmp3ext, 16 38 %Mext = sext i8 %M to i16 39 %add2 = add nsw i16 %tmp3ext, %Mext 40 %arrayidx = getelementptr inbounds i8, i8* %A, i16 %add2 41 %tmp4 = load i8, i8* %arrayidx, align 4 42 %inc = add nsw i8 %tmp4, 1 43 store i8 %inc, i8* %arrayidx, align 4 44 br label %for.inc 45 46for.inc: ; preds = %for.body 47 %indvars.iv.next = add nuw nsw i8 %indvars.iv, 1 48 br label %for.cond 49 50for.end: ; preds = %for.cond 51 ret void 52} 53 54define void @slow(i8* %A, i8 %N, i8 %M) { 55entry: 56 br label %for.cond 57 58for.cond: ; preds = %for.inc, %entry 59 %indvars.iv = phi i8 [ %indvars.iv.next, %for.inc ], [ 0, %entry ] 60 %exitcond = icmp ne i8 %indvars.iv, 8 61 br i1 %exitcond, label %for.body, label %for.end 62 63for.body: ; preds = %for.cond 64 %tmp3 = add nsw i8 %indvars.iv, %N 65 %tmp3ext = sext i8 %tmp3 to i16 66 %mul = mul nsw i16 %tmp3ext, 16 67 %Mext = sext i8 %M to i16 68 %add2 = add nsw i16 %mul, %Mext 69 %arrayidx = getelementptr inbounds i8, i8* %A, i16 %add2 70 %tmp4 = load i8, i8* %arrayidx, align 4 71 %inc = add nsw i8 %tmp4, 1 72 store i8 %inc, i8* %arrayidx, align 4 73 br label %for.inc 74 75for.inc: ; preds = %for.body 76 %indvars.iv.next = add nuw nsw i8 %indvars.iv, 1 77 br label %for.cond 78 79for.end: ; preds = %for.cond 80 ret void 81} 82