1 ; RUN: opt -S -simplifycfg < %s | FileCheck %s
3 define i32 @speculate_vector_extract(i32 %d, <4 x i32> %v) #0 {
4 ; CHECK-LABEL: @speculate_vector_extract(
7 %conv = insertelement <4 x i32> undef, i32 %d, i32 0
8 %conv2 = insertelement <4 x i32> %conv, i32 %d, i32 1
9 %conv3 = insertelement <4 x i32> %conv2, i32 %d, i32 2
10 %conv4 = insertelement <4 x i32> %conv3, i32 %d, i32 3
11 %tmp6 = add nsw <4 x i32> %conv4, <i32 0, i32 -1, i32 -2, i32 -3>
12 %cmp = icmp eq <4 x i32> %tmp6, zeroinitializer
13 %cmp.ext = sext <4 x i1> %cmp to <4 x i32>
14 %tmp8 = extractelement <4 x i32> %cmp.ext, i32 0
15 %tobool = icmp eq i32 %tmp8, 0
16 br i1 %tobool, label %cond.else, label %cond.then
18 return: ; preds = %cond.end28
21 cond.then: ; preds = %entry
22 %tmp10 = extractelement <4 x i32> %v, i32 0
25 cond.else: ; preds = %entry
26 %tmp12 = extractelement <4 x i32> %v, i32 3
29 cond.end: ; preds = %cond.else, %cond.then
30 %cond = phi i32 [ %tmp10, %cond.then ], [ %tmp12, %cond.else ]
31 %tmp14 = extractelement <4 x i32> %cmp.ext, i32 1
32 %tobool15 = icmp eq i32 %tmp14, 0
33 br i1 %tobool15, label %cond.else17, label %cond.then16
35 cond.then16: ; preds = %cond.end
36 %tmp20 = extractelement <4 x i32> %v, i32 1
39 cond.else17: ; preds = %cond.end
42 cond.end18: ; preds = %cond.else17, %cond.then16
43 %cond22 = phi i32 [ %tmp20, %cond.then16 ], [ %cond, %cond.else17 ]
44 %tmp24 = extractelement <4 x i32> %cmp.ext, i32 2
45 %tobool25 = icmp eq i32 %tmp24, 0
46 br i1 %tobool25, label %cond.else27, label %cond.then26
48 cond.then26: ; preds = %cond.end18
49 %tmp30 = extractelement <4 x i32> %v, i32 2
52 cond.else27: ; preds = %cond.end18
55 cond.end28: ; preds = %cond.else27, %cond.then26
56 %cond32 = phi i32 [ %tmp30, %cond.then26 ], [ %cond22, %cond.else27 ]
60 attributes #0 = { nounwind }