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