1cee313d2SEric Christopher; RUN: opt < %s  -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -S | FileCheck %s
2cee313d2SEric Christopher
3cee313d2SEric Christophertarget 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-S128"
4cee313d2SEric Christopher
5cee313d2SEric Christopherdefine void @add_ints(i32* nocapture %A, i32* nocapture %B, i32* nocapture %C) {
6ef4df279SFlorian Hahn; CHECK-LABEL: @add_ints(
7*b7315ffcSFlorian Hahn; CHECK-NEXT:  entry:
8*b7315ffcSFlorian Hahn; CHECK-NEXT:    br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_MEMCHECK:%.*]]
9872f7000SDávid Bolvanský; CHECK-LABEL: vector.memcheck:
10*b7315ffcSFlorian Hahn; CHECK-NEXT:    [[A1:%.*]] = ptrtoint i32* [[A:%.*]] to i64
11*b7315ffcSFlorian Hahn; CHECK-NEXT:    [[B2:%.*]] = ptrtoint i32* [[B:%.*]] to i64
12*b7315ffcSFlorian Hahn; CHECK-NEXT:    [[C3:%.*]] = ptrtoint i32* [[C:%.*]] to i64
13*b7315ffcSFlorian Hahn; CHECK-NEXT:    [[TMP0:%.*]] = sub i64 [[A1]], [[B2]]
14*b7315ffcSFlorian Hahn; CHECK-NEXT:    [[DIFF_CHECK:%.*]] = icmp ult i64 [[TMP0]], 16
15*b7315ffcSFlorian Hahn; CHECK-NEXT:    [[TMP1:%.*]] = sub i64 [[A1]], [[C3]]
16*b7315ffcSFlorian Hahn; CHECK-NEXT:    [[DIFF_CHECK4:%.*]] = icmp ult i64 [[TMP1]], 16
17*b7315ffcSFlorian Hahn; CHECK-NEXT:    [[CONFLICT_RDX:%.*]] = or i1 [[DIFF_CHECK]], [[DIFF_CHECK4]]
18*b7315ffcSFlorian Hahn; CHECK-NEXT:    br i1 [[CONFLICT_RDX]], label [[SCALAR_PH]], label [[VECTOR_PH:%.*]]
19ef4df279SFlorian Hahn; CHECK:       vector.ph:
20872f7000SDávid Bolvanský; CHECK-NEXT:    br label %vector.body
21ef4df279SFlorian Hahn; CHECK:       vector.body:
22ef4df279SFlorian Hahn;
23cee313d2SEric Christopherentry:
24cee313d2SEric Christopher  br label %for.body
25cee313d2SEric Christopher
26cee313d2SEric Christopherfor.body:
27cee313d2SEric Christopher  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
28cee313d2SEric Christopher  %arrayidx = getelementptr inbounds i32, i32* %B, i64 %indvars.iv
29cee313d2SEric Christopher  %0 = load i32, i32* %arrayidx, align 4
30cee313d2SEric Christopher  %arrayidx2 = getelementptr inbounds i32, i32* %C, i64 %indvars.iv
31cee313d2SEric Christopher  %1 = load i32, i32* %arrayidx2, align 4
32cee313d2SEric Christopher  %add = add nsw i32 %1, %0
33cee313d2SEric Christopher  %arrayidx4 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
34cee313d2SEric Christopher  store i32 %add, i32* %arrayidx4, align 4
35cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1
36cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
37cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, 200
38cee313d2SEric Christopher  br i1 %exitcond, label %for.end, label %for.body
39cee313d2SEric Christopher
40cee313d2SEric Christopherfor.end:
41cee313d2SEric Christopher  ret void
42cee313d2SEric Christopher}
43