Fix test failures introduced by PR #113697 (#116941)
[llvm-project.git] / llvm / test / Transforms / LoopVectorize / X86 / replicate-recipe-with-only-first-lane-used.ll
blobe6c9ce3381f73f27b87b218f2e20ef5169c90709
1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=2 -S %s | FileCheck %s
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 ; Test case for https://github.com/llvm/llvm-project/issues/111042.
8 define void @replicate_udiv_with_only_first_lane_used(i32 %x, ptr %dst, i64 %d) {
9 ; CHECK-LABEL: define void @replicate_udiv_with_only_first_lane_used(
10 ; CHECK-SAME: i32 [[X:%.*]], ptr [[DST:%.*]], i64 [[D:%.*]]) {
11 ; CHECK-NEXT:  [[ENTRY:.*]]:
12 ; CHECK-NEXT:    [[C:%.*]] = icmp eq i32 [[X]], 10
13 ; CHECK-NEXT:    br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]
14 ; CHECK:       [[VECTOR_PH]]:
15 ; CHECK-NEXT:    br label %[[VECTOR_BODY:.*]]
16 ; CHECK:       [[VECTOR_BODY]]:
17 ; CHECK-NEXT:    [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[PRED_UDIV_CONTINUE14:.*]] ]
18 ; CHECK-NEXT:    br i1 false, label %[[PRED_UDIV_IF:.*]], label %[[PRED_UDIV_CONTINUE:.*]]
19 ; CHECK:       [[PRED_UDIV_IF]]:
20 ; CHECK-NEXT:    [[TMP0:%.*]] = udiv i64 99, [[D]]
21 ; CHECK-NEXT:    br label %[[PRED_UDIV_CONTINUE]]
22 ; CHECK:       [[PRED_UDIV_CONTINUE]]:
23 ; CHECK-NEXT:    [[TMP1:%.*]] = phi i64 [ poison, %[[VECTOR_BODY]] ], [ [[TMP0]], %[[PRED_UDIV_IF]] ]
24 ; CHECK-NEXT:    br i1 false, label %[[PRED_UDIV_IF1:.*]], label %[[PRED_UDIV_CONTINUE2:.*]]
25 ; CHECK:       [[PRED_UDIV_IF1]]:
26 ; CHECK-NEXT:    [[TMP2:%.*]] = udiv i64 99, [[D]]
27 ; CHECK-NEXT:    br label %[[PRED_UDIV_CONTINUE2]]
28 ; CHECK:       [[PRED_UDIV_CONTINUE2]]:
29 ; CHECK-NEXT:    br i1 false, label %[[PRED_UDIV_IF3:.*]], label %[[PRED_UDIV_CONTINUE4:.*]]
30 ; CHECK:       [[PRED_UDIV_IF3]]:
31 ; CHECK-NEXT:    [[TMP3:%.*]] = udiv i64 99, [[D]]
32 ; CHECK-NEXT:    br label %[[PRED_UDIV_CONTINUE4]]
33 ; CHECK:       [[PRED_UDIV_CONTINUE4]]:
34 ; CHECK-NEXT:    br i1 false, label %[[PRED_UDIV_IF5:.*]], label %[[PRED_UDIV_CONTINUE6:.*]]
35 ; CHECK:       [[PRED_UDIV_IF5]]:
36 ; CHECK-NEXT:    [[TMP4:%.*]] = udiv i64 99, [[D]]
37 ; CHECK-NEXT:    br label %[[PRED_UDIV_CONTINUE6]]
38 ; CHECK:       [[PRED_UDIV_CONTINUE6]]:
39 ; CHECK-NEXT:    br i1 false, label %[[PRED_UDIV_IF7:.*]], label %[[PRED_UDIV_CONTINUE8:.*]]
40 ; CHECK:       [[PRED_UDIV_IF7]]:
41 ; CHECK-NEXT:    [[TMP5:%.*]] = udiv i64 99, [[D]]
42 ; CHECK-NEXT:    br label %[[PRED_UDIV_CONTINUE8]]
43 ; CHECK:       [[PRED_UDIV_CONTINUE8]]:
44 ; CHECK-NEXT:    [[TMP6:%.*]] = phi i64 [ poison, %[[PRED_UDIV_CONTINUE6]] ], [ [[TMP5]], %[[PRED_UDIV_IF7]] ]
45 ; CHECK-NEXT:    br i1 false, label %[[PRED_UDIV_IF9:.*]], label %[[PRED_UDIV_CONTINUE10:.*]]
46 ; CHECK:       [[PRED_UDIV_IF9]]:
47 ; CHECK-NEXT:    [[TMP7:%.*]] = udiv i64 99, [[D]]
48 ; CHECK-NEXT:    br label %[[PRED_UDIV_CONTINUE10]]
49 ; CHECK:       [[PRED_UDIV_CONTINUE10]]:
50 ; CHECK-NEXT:    br i1 false, label %[[PRED_UDIV_IF11:.*]], label %[[PRED_UDIV_CONTINUE12:.*]]
51 ; CHECK:       [[PRED_UDIV_IF11]]:
52 ; CHECK-NEXT:    [[TMP8:%.*]] = udiv i64 99, [[D]]
53 ; CHECK-NEXT:    br label %[[PRED_UDIV_CONTINUE12]]
54 ; CHECK:       [[PRED_UDIV_CONTINUE12]]:
55 ; CHECK-NEXT:    br i1 false, label %[[PRED_UDIV_IF13:.*]], label %[[PRED_UDIV_CONTINUE14]]
56 ; CHECK:       [[PRED_UDIV_IF13]]:
57 ; CHECK-NEXT:    [[TMP9:%.*]] = udiv i64 99, [[D]]
58 ; CHECK-NEXT:    br label %[[PRED_UDIV_CONTINUE14]]
59 ; CHECK:       [[PRED_UDIV_CONTINUE14]]:
60 ; CHECK-NEXT:    [[PREDPHI:%.*]] = select i1 true, i64 0, i64 [[TMP1]]
61 ; CHECK-NEXT:    [[PREDPHI15:%.*]] = select i1 true, i64 0, i64 [[TMP6]]
62 ; CHECK-NEXT:    [[TMP10:%.*]] = getelementptr i16, ptr [[DST]], i64 [[PREDPHI]]
63 ; CHECK-NEXT:    [[TMP11:%.*]] = getelementptr i16, ptr [[DST]], i64 [[PREDPHI15]]
64 ; CHECK-NEXT:    store i16 0, ptr [[TMP10]], align 2
65 ; CHECK-NEXT:    store i16 0, ptr [[TMP11]], align 2
66 ; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 8
67 ; CHECK-NEXT:    [[TMP12:%.*]] = icmp eq i64 [[INDEX_NEXT]], 96
68 ; CHECK-NEXT:    br i1 [[TMP12]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
69 ; CHECK:       [[MIDDLE_BLOCK]]:
70 ; CHECK-NEXT:    br i1 false, label %[[EXIT:.*]], label %[[SCALAR_PH]]
71 ; CHECK:       [[SCALAR_PH]]:
72 ; CHECK-NEXT:    [[BC_RESUME_VAL:%.*]] = phi i64 [ 96, %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]
73 ; CHECK-NEXT:    br label %[[LOOP_HEADER:.*]]
74 ; CHECK:       [[LOOP_HEADER]]:
75 ; CHECK-NEXT:    [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
76 ; CHECK-NEXT:    br i1 true, label %[[LOOP_LATCH]], label %[[ELSE:.*]]
77 ; CHECK:       [[ELSE]]:
78 ; CHECK-NEXT:    [[DIV_I:%.*]] = udiv i64 99, [[D]]
79 ; CHECK-NEXT:    br label %[[LOOP_LATCH]]
80 ; CHECK:       [[LOOP_LATCH]]:
81 ; CHECK-NEXT:    [[RETVAL_0_I:%.*]] = phi i64 [ [[DIV_I]], %[[ELSE]] ], [ 0, %[[LOOP_HEADER]] ]
82 ; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i16, ptr [[DST]], i64 [[RETVAL_0_I]]
83 ; CHECK-NEXT:    store i16 0, ptr [[GEP]], align 2
84 ; CHECK-NEXT:    [[IV_NEXT]] = add i64 [[IV]], 1
85 ; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i64 [[IV_NEXT]], 101
86 ; CHECK-NEXT:    br i1 [[CMP]], label %[[LOOP_HEADER]], label %[[EXIT]], !llvm.loop [[LOOP3:![0-9]+]]
87 ; CHECK:       [[EXIT]]:
88 ; CHECK-NEXT:    ret void
90 entry:
91   %c = icmp eq i32 %x, 10
92   br label %loop.header
94 loop.header:                                         ; preds = %loop.latch, %entry
95   %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
96   br i1 true, label %loop.latch, label %else
98 else:
99   %div.i = udiv i64 99, %d
100   br label %loop.latch
102 loop.latch:
103   %retval.0.i = phi i64 [ %div.i, %else ], [ 0, %loop.header ]
104   %gep = getelementptr i16, ptr %dst, i64 %retval.0.i
105   store i16 0, ptr %gep, align 2
106   %iv.next = add i64 %iv, 1
107   %cmp = icmp ult i64 %iv.next, 101
108   br i1 %cmp, label %loop.header, label %exit
110 exit:
111   ret void
114 ; CHECK: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]], [[META2:![0-9]+]]}
115 ; CHECK: [[META1]] = !{!"llvm.loop.isvectorized", i32 1}
116 ; CHECK: [[META2]] = !{!"llvm.loop.unroll.runtime.disable"}
117 ; CHECK: [[LOOP3]] = distinct !{[[LOOP3]], [[META2]], [[META1]]}