• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s  -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -enable-if-conversion -dce -instcombine -S | FileCheck %s
2
3target 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"
4
5;CHECK-LABEL: @foo(
6;CHECK: icmp sgt
7;CHECK: icmp sgt
8;CHECK: icmp slt
9;CHECK: select <4 x i1>
10;CHECK: %[[P1:.*]] = select <4 x i1>
11;CHECK: xor <4 x i1>
12;CHECK: and <4 x i1>
13;CHECK: select <4 x i1> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %[[P1]]
14;CHECK: ret
15define i32 @foo(i32* nocapture %A, i32* nocapture %B, i32 %n) {
16entry:
17  %cmp26 = icmp sgt i32 %n, 0
18  br i1 %cmp26, label %for.body, label %for.end
19
20for.body:
21  %indvars.iv = phi i64 [ %indvars.iv.next, %if.end14 ], [ 0, %entry ]
22  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
23  %0 = load i32, i32* %arrayidx, align 4
24  %arrayidx2 = getelementptr inbounds i32, i32* %B, i64 %indvars.iv
25  %1 = load i32, i32* %arrayidx2, align 4
26  %cmp3 = icmp sgt i32 %0, %1
27  br i1 %cmp3, label %if.then, label %if.end14
28
29if.then:
30  %cmp6 = icmp sgt i32 %0, 19
31  br i1 %cmp6, label %if.end14, label %if.else
32
33if.else:
34  %cmp10 = icmp slt i32 %1, 4
35  %. = select i1 %cmp10, i32 4, i32 5
36  br label %if.end14
37
38if.end14:
39  %x.0 = phi i32 [ 9, %for.body ], [ 3, %if.then ], [ %., %if.else ]  ; <------------- A PHI with 3 entries that we can still vectorize.
40  store i32 %x.0, i32* %arrayidx, align 4
41  %indvars.iv.next = add i64 %indvars.iv, 1
42  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
43  %exitcond = icmp eq i32 %lftr.wideiv, %n
44  br i1 %exitcond, label %for.end, label %for.body
45
46for.end:
47  ret i32 undef
48}
49