2015-10-06 23:36:44 +08:00
|
|
|
; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
|
2013-06-15 00:23:38 +08:00
|
|
|
|
|
|
|
; Check that we correctly convert integers to isl values.
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
; Large positive integer
|
|
|
|
define void @f(i1024* nocapture %a) nounwind {
|
|
|
|
entry:
|
|
|
|
br label %bb
|
|
|
|
|
|
|
|
bb:
|
|
|
|
%indvar = phi i1024 [ 0, %entry ], [ %indvar.next, %bb ]
|
2015-09-16 06:52:53 +08:00
|
|
|
store i1024 %indvar, i1024* %a, align 8
|
2013-06-15 00:23:38 +08:00
|
|
|
%indvar.next = add nsw i1024 %indvar, 1
|
|
|
|
%exitcond = icmp eq i1024 %indvar, 123456000000000000000000000
|
|
|
|
; CHECK: 'bb => return' in function 'f'
|
|
|
|
; CHECK: i0 <= 123456000000000000000000000
|
|
|
|
br i1 %exitcond, label %return, label %bb
|
|
|
|
|
|
|
|
return:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Normal positive integer
|
|
|
|
define void @f2(i32* nocapture %a) nounwind {
|
|
|
|
entry:
|
|
|
|
br label %bb
|
|
|
|
|
|
|
|
bb:
|
|
|
|
%indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb ]
|
2015-02-28 03:20:19 +08:00
|
|
|
%scevgep = getelementptr i32, i32* %a, i32 %indvar
|
2013-06-15 00:23:38 +08:00
|
|
|
store i32 %indvar, i32* %scevgep, align 8
|
|
|
|
%indvar.next = add nsw i32 %indvar, 1
|
|
|
|
%exitcond = icmp eq i32 %indvar, 123456
|
|
|
|
; CHECK: 'bb => return' in function 'f2'
|
|
|
|
; CHECK: i0 <= 123456
|
|
|
|
br i1 %exitcond, label %return, label %bb
|
|
|
|
|
|
|
|
return:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Normal negative integer
|
|
|
|
define void @f3(i32* nocapture %a, i32 %n) nounwind {
|
|
|
|
entry:
|
|
|
|
br label %bb
|
|
|
|
|
|
|
|
bb:
|
|
|
|
%indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb ]
|
2015-02-28 03:20:19 +08:00
|
|
|
%scevgep = getelementptr i32, i32* %a, i32 %indvar
|
2013-06-15 00:23:38 +08:00
|
|
|
store i32 %indvar, i32* %scevgep, align 8
|
|
|
|
%indvar.next = add nsw i32 %indvar, 1
|
|
|
|
%sub = sub i32 %n, 123456
|
|
|
|
%exitcond = icmp eq i32 %indvar, %sub
|
|
|
|
; CHECK: 'bb => return' in function 'f3'
|
|
|
|
; CHECK: -123456
|
|
|
|
br i1 %exitcond, label %return, label %bb
|
|
|
|
|
|
|
|
return:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Large negative integer
|
|
|
|
define void @f4(i1024* nocapture %a, i1024 %n) nounwind {
|
|
|
|
entry:
|
|
|
|
br label %bb
|
|
|
|
|
|
|
|
bb:
|
|
|
|
%indvar = phi i1024 [ 0, %entry ], [ %indvar.next, %bb ]
|
2015-02-28 03:20:19 +08:00
|
|
|
%scevgep = getelementptr i1024, i1024* %a, i1024 %indvar
|
2013-06-15 00:23:38 +08:00
|
|
|
store i1024 %indvar, i1024* %scevgep, align 8
|
|
|
|
%indvar.next = add nsw i1024 %indvar, 1
|
|
|
|
%sub = sub i1024 %n, 123456000000000000000000000000000000
|
|
|
|
; CHECK: 'bb => return' in function 'f4'
|
|
|
|
; CHECK: -123456000000000000000000000000000000
|
|
|
|
%exitcond = icmp eq i1024 %indvar, %sub
|
|
|
|
br i1 %exitcond, label %return, label %bb
|
|
|
|
|
|
|
|
return:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @f5(i1023* nocapture %a, i1023 %n) nounwind {
|
|
|
|
entry:
|
|
|
|
br label %bb
|
|
|
|
|
|
|
|
bb:
|
|
|
|
%indvar = phi i1023 [ 0, %entry ], [ %indvar.next, %bb ]
|
2015-02-28 03:20:19 +08:00
|
|
|
%scevgep = getelementptr i1023, i1023* %a, i1023 %indvar
|
2013-06-15 00:23:38 +08:00
|
|
|
store i1023 %indvar, i1023* %scevgep, align 8
|
|
|
|
%indvar.next = add nsw i1023 %indvar, 1
|
|
|
|
%sub = sub i1023 %n, 123456000000000000000000000000000000
|
|
|
|
; CHECK: 'bb => return' in function 'f5'
|
|
|
|
; CHECK: -123456000000000000000000000000000000
|
|
|
|
%exitcond = icmp eq i1023 %indvar, %sub
|
|
|
|
br i1 %exitcond, label %return, label %bb
|
|
|
|
|
|
|
|
return:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Tiny negative integer
|
|
|
|
define void @f6(i3* nocapture %a, i3 %n) nounwind {
|
|
|
|
entry:
|
|
|
|
br label %bb
|
|
|
|
|
|
|
|
bb:
|
|
|
|
%indvar = phi i3 [ 0, %entry ], [ %indvar.next, %bb ]
|
2015-02-28 03:20:19 +08:00
|
|
|
%scevgep = getelementptr i3, i3* %a, i3 %indvar
|
2013-06-15 00:23:38 +08:00
|
|
|
store i3 %indvar, i3* %scevgep, align 8
|
|
|
|
%indvar.next = add nsw i3 %indvar, 1
|
|
|
|
%sub = sub i3 %n, 3
|
[SCEVAffinator] Make precise modular math more correct.
Integer math in LLVM IR is modular. Integer math in isl is
arbitrary-precision. Modeling LLVM IR math correctly in isl requires
either adding assumptions that math doesn't actually overflow, or
explicitly wrapping the math. However, expressions with the "nsw" flag
are special; we can pretend they're arbitrary-precision because it's
undefined behavior if the result wraps. SCEV expressions based on IR
instructions with an nsw flag also carry an nsw flag (roughly; actually,
the real rule is a bit more complicated, but the details don't matter
here).
Before this patch, SCEV flags were also overloaded with an additional
function: the ZExt code was mutating SCEV expressions as a hack to
indicate to checkForWrapping that we don't need to add assumptions to
the operand of a ZExt; it'll add explicit wrapping itself. This kind of
works... the problem is that if anything else ever touches that SCEV
expression, it'll get confused by the incorrect flags.
Instead, with this patch, we make the decision about whether to
explicitly wrap the math a bit earlier, basing the decision purely on
the SCEV expression itself, and not its users.
Differential Revision: https://reviews.llvm.org/D25287
llvm-svn: 284848
2016-10-22 02:08:02 +08:00
|
|
|
; CHECK-LABEL: 'bb => return' in function 'f6'
|
|
|
|
; CHECK: Context:
|
|
|
|
; CHECK-NEXT: [n] -> { : -4 <= n <= 3 }
|
|
|
|
; CHECK-NEXT: Assumed Context:
|
|
|
|
; CHECK-NEXT: [n] -> { : }
|
|
|
|
; CHECK-NEXT: Invalid Context:
|
|
|
|
; CHECK-NEXT: [n] -> { : 1 = 0 }
|
|
|
|
|
|
|
|
; CHECK: Statements {
|
|
|
|
; CHECK-NEXT: Stmt_bb
|
|
|
|
; CHECK-NEXT: Domain :=
|
|
|
|
; CHECK-NEXT: [n] -> { Stmt_bb[i0] : i0 >= 0 and 8*floor((2 - n)/8) >= -5 - n + i0 and 8*floor((2 - n)/8) <= -2 - n };
|
|
|
|
; CHECK-NEXT: Schedule :=
|
|
|
|
; CHECK-NEXT: [n] -> { Stmt_bb[i0] -> [i0] };
|
|
|
|
; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
|
|
|
|
; CHECK-NEXT: [n] -> { Stmt_bb[i0] -> MemRef_a[i0] };
|
|
|
|
; CHECK-NEXT:}
|
|
|
|
|
2013-06-15 00:23:38 +08:00
|
|
|
%exitcond = icmp eq i3 %indvar, %sub
|
|
|
|
br i1 %exitcond, label %return, label %bb
|
|
|
|
|
|
|
|
return:
|
|
|
|
ret void
|
|
|
|
}
|