1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -slp-vectorizer -S -mtriple=x86_64-pc-windows-msvc19.29.30145 < %s | FileCheck %s
3
4; This used to crash in SLP vectorization when attempting to set the
5; IRBuilder's insertion point to the end of a catchswitch block, which
6; is invalid.  Only phis and the catchswitch may be present, so we must
7; avoid trying to insert shuffles into such a block.
8
9%typeA = type { i8**, i8*, [20 x i8] }
10@globalA = external global %typeA
11
12declare i32 @__CxxFrameHandler3(...)
13declare void @funcA()
14
15define void @important_func() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
16; CHECK-LABEL: @important_func(
17; CHECK-NEXT:  entry:
18; CHECK-NEXT:    br label [[LABELB:%.*]]
19; CHECK:       labelB:
20; CHECK-NEXT:    invoke void @funcA()
21; CHECK-NEXT:    to label [[LABELC:%.*]] unwind label [[LABELD:%.*]]
22; CHECK:       labelC:
23; CHECK-NEXT:    invoke void @funcA()
24; CHECK-NEXT:    to label [[LABELE:%.*]] unwind label [[LABELF:%.*]]
25; CHECK:       labelD:
26; CHECK-NEXT:    [[TMP0:%.*]] = cleanuppad within none []
27; CHECK-NEXT:    unreachable
28; CHECK:       labelE:
29; CHECK-NEXT:    [[TMP1:%.*]] = extractelement <4 x float> <float 0x7FF0000000000000, float 0x7FF0000000000000, float 0x7FF0000000000000, float 0xFFF0000000000000>, i64 1
30; CHECK-NEXT:    [[F:%.*]] = extractelement <4 x float> <float 0x7FF0000000000000, float 0x7FF0000000000000, float 0x7FF0000000000000, float 0xFFF0000000000000>, i64 2
31; CHECK-NEXT:    invoke void @funcA()
32; CHECK-NEXT:    to label [[LABELG:%.*]] unwind label [[CATCH_DISPATCH:%.*]]
33; CHECK:       labelF:
34; CHECK-NEXT:    [[TMP2:%.*]] = cleanuppad within none []
35; CHECK-NEXT:    cleanupret from [[TMP2]] unwind to caller
36; CHECK:       labelG:
37; CHECK-NEXT:    [[G:%.*]] = extractelement <4 x float> <float 0x7FF0000000000000, float 0x7FF0000000000000, float 0x7FF0000000000000, float 0xFFF0000000000000>, i64 0
38; CHECK-NEXT:    [[H:%.*]] = extractelement <4 x float> <float 0x7FF0000000000000, float 0x7FF0000000000000, float 0x7FF0000000000000, float 0xFFF0000000000000>, i64 3
39; CHECK-NEXT:    invoke void @funcA()
40; CHECK-NEXT:    to label [[LABELH:%.*]] unwind label [[CATCH_DISPATCH]]
41; CHECK:       labelH:
42; CHECK-NEXT:    unreachable
43; CHECK:       catch.dispatch:
44; CHECK-NEXT:    [[TMP3:%.*]] = phi float [ [[G]], [[LABELG]] ], [ [[TMP1]], [[LABELE]] ]
45; CHECK-NEXT:    [[TMP4:%.*]] = phi float [ [[H]], [[LABELG]] ], [ [[F]], [[LABELE]] ]
46; CHECK-NEXT:    [[TMP5:%.*]] = catchswitch within none [label %catch] unwind to caller
47; CHECK:       catch:
48; CHECK-NEXT:    [[TMP6:%.*]] = catchpad within [[TMP5]] [%typeA* @globalA, i32 8, i8* null]
49; CHECK-NEXT:    unreachable
50;
51entry:
52  br label %labelB
53
54labelB:
55  invoke void @funcA()
56  to label %labelC unwind label %labelD
57
58labelC:
59  invoke void @funcA()
60  to label %labelE unwind label %labelF
61
62labelD:
63  %0 = cleanuppad within none []
64  unreachable
65
66labelE:
67  %1 = extractelement <4 x float> <float 0x7FF0000000000000, float 0x7FF0000000000000, float 0x7FF0000000000000, float 0xFFF0000000000000>, i64 1
68  %f = extractelement <4 x float> <float 0x7FF0000000000000, float 0x7FF0000000000000, float 0x7FF0000000000000, float 0xFFF0000000000000>, i64 2
69  invoke void @funcA()
70  to label %labelG unwind label %catch.dispatch
71
72labelF:
73  %2 = cleanuppad within none []
74  cleanupret from %2 unwind to caller
75
76labelG:
77  %g = extractelement <4 x float> <float 0x7FF0000000000000, float 0x7FF0000000000000, float 0x7FF0000000000000, float 0xFFF0000000000000>, i64 0
78  %h = extractelement <4 x float> <float 0x7FF0000000000000, float 0x7FF0000000000000, float 0x7FF0000000000000, float 0xFFF0000000000000>, i64 3
79  invoke void @funcA()
80  to label %labelH unwind label %catch.dispatch
81
82labelH:
83  unreachable
84
85catch.dispatch:
86  %3 = phi float [ %g, %labelG ], [ %1, %labelE ]
87  %4 = phi float [ %h, %labelG ], [ %f, %labelE ]
88  %5 = catchswitch within none [label %catch] unwind to caller
89
90catch:
91  %6 = catchpad within %5 [%typeA* @globalA, i32 8, i8* null]
92  unreachable
93}
94