1*5c028081SMichael Kruse; RUN: opt %loadPolly -polly-print-ast -disable-output < %s | FileCheck %s
235f70200SMichael Kruse; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s -check-prefix=CODEGEN
335f70200SMichael Kruse;
435f70200SMichael Kruse
535f70200SMichael Kruse;    void f(int a[], int N, float *P, float *Q) {
635f70200SMichael Kruse;      int i;
735f70200SMichael Kruse;      for (i = 0; i < N; ++i)
835f70200SMichael Kruse;        if (P != Q)
935f70200SMichael Kruse;          a[i] = i;
1035f70200SMichael Kruse;    }
1135f70200SMichael Kruse;
1235f70200SMichael Krusetarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
1335f70200SMichael Kruse
1435f70200SMichael Krusedefine void @f(i64* nocapture %a, i64 %N, float * %P, float * %Q) nounwind {
1535f70200SMichael Kruseentry:
1635f70200SMichael Kruse  br label %bb
1735f70200SMichael Kruse
1835f70200SMichael Krusebb:
1935f70200SMichael Kruse  %i = phi i64 [ 0, %entry ], [ %i.inc, %bb.backedge ]
2035f70200SMichael Kruse  %brcond = icmp ne float* %P, %Q
2135f70200SMichael Kruse  br i1 %brcond, label %store, label %bb.backedge
2235f70200SMichael Kruse
2335f70200SMichael Krusestore:
2435f70200SMichael Kruse  %scevgep = getelementptr inbounds i64, i64* %a, i64 %i
2535f70200SMichael Kruse  store i64 %i, i64* %scevgep
2635f70200SMichael Kruse  br label %bb.backedge
2735f70200SMichael Kruse
2835f70200SMichael Krusebb.backedge:
2935f70200SMichael Kruse  %i.inc = add nsw i64 %i, 1
3035f70200SMichael Kruse  %exitcond = icmp eq i64 %i.inc, %N
3135f70200SMichael Kruse  br i1 %exitcond, label %return, label %bb
3235f70200SMichael Kruse
3335f70200SMichael Krusereturn:
3435f70200SMichael Kruse  ret void
3535f70200SMichael Kruse}
3635f70200SMichael Kruse
3735f70200SMichael Kruse; CHECK:      if (Q >= P + 1 || P >= Q + 1)
3835f70200SMichael Kruse; CHECK-NEXT:   for (int c0 = 0; c0 < N; c0 += 1)
3935f70200SMichael Kruse; CHECK-NEXT:     Stmt_store(c0);
4035f70200SMichael Kruse
4135f70200SMichael Kruse; CODEGEN:       polly.cond:
4235f70200SMichael Kruse; CODEGEN-NEXT:  %[[Q:[_a-zA-Z0-9]+]] = ptrtoint float* %Q to i64
4335f70200SMichael Kruse; CODEGEN-NEXT:  %[[P:[_a-zA-Z0-9]+]] = ptrtoint float* %P to i64
4435f70200SMichael Kruse; CODEGEN-NEXT:  %[[PInc:[_a-zA-Z0-9]+]] = add nsw i64 %[[P]], 1
4535f70200SMichael Kruse; CODEGEN-NEXT:  %[[CMP:[_a-zA-Z0-9]+]] = icmp sge i64 %[[Q]], %[[PInc]]
4635f70200SMichael Kruse; CODEGEN-NEXT:  %[[P2:[_a-zA-Z0-9]+]] = ptrtoint float* %P to i64
4735f70200SMichael Kruse; CODEGEN-NEXT:  %[[Q2:[_a-zA-Z0-9]+]] = ptrtoint float* %Q to i64
4835f70200SMichael Kruse; CODEGEN-NEXT:  %[[QInc:[_a-zA-Z0-9]+]] = add nsw i64 %[[Q2]], 1
4935f70200SMichael Kruse; CODEGEN-NEXT:  %[[CMP2:[_a-zA-Z0-9]+]] = icmp sge i64 %[[P2]], %[[QInc]]
5035f70200SMichael Kruse; CODEGEN-NEXT:  %[[CMP3:[_a-zA-Z0-9]+]] = or i1 %[[CMP]], %[[CMP2]]
5135f70200SMichael Kruse; CODEGEN-NEXT:  br i1 %[[CMP3]]
52