aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/Transforms/PhaseOrdering/X86/pr48223.ll
blob: 459c6c5b9ffb371a173f5d2719455dde7d38d5a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -O3 -S -mtriple=x86_64-- -mcpu=x86-64    < %s | FileCheck %s
; RUN: opt -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v2 < %s | FileCheck %s
; RUN: opt -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v3 < %s | FileCheck %s
; RUN: opt -O3 -S -mtriple=x86_64-- -mcpu=x86-64-v4 < %s | FileCheck %s

%"struct.std::array" = type { [8 x i16] }

define { i64, i64 } @compute_min(ptr noundef nonnull align 2 dereferenceable(16) %x, ptr noundef nonnull align 2 dereferenceable(16) %y) {
; CHECK-LABEL: @compute_min(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[PT1_4:%.*]] = getelementptr inbounds nuw i8, ptr [[X:%.*]], i64 8
; CHECK-NEXT:    [[PT0_4:%.*]] = getelementptr inbounds nuw i8, ptr [[Y:%.*]], i64 8
; CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i16>, ptr [[Y]], align 2
; CHECK-NEXT:    [[TMP1:%.*]] = load <4 x i16>, ptr [[X]], align 2
; CHECK-NEXT:    [[TMP2:%.*]] = tail call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
; CHECK-NEXT:    [[TMP5:%.*]] = bitcast <4 x i16> [[TMP2]] to i64
; CHECK-NEXT:    [[DOTFCA_0_INSERT:%.*]] = insertvalue { i64, i64 } poison, i64 [[TMP5]], 0
; CHECK-NEXT:    [[TMP6:%.*]] = load <4 x i16>, ptr [[PT0_4]], align 2
; CHECK-NEXT:    [[TMP7:%.*]] = load <4 x i16>, ptr [[PT1_4]], align 2
; CHECK-NEXT:    [[TMP8:%.*]] = tail call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP6]], <4 x i16> [[TMP7]])
; CHECK-NEXT:    [[TMP11:%.*]] = bitcast <4 x i16> [[TMP8]] to i64
; CHECK-NEXT:    [[DOTFCA_1_INSERT:%.*]] = insertvalue { i64, i64 } [[DOTFCA_0_INSERT]], i64 [[TMP11]], 1
; CHECK-NEXT:    ret { i64, i64 } [[DOTFCA_1_INSERT]]
;
entry:
  %retval = alloca %"struct.std::array", align 2
  br label %for.cond

for.cond:                                         ; preds = %for.body, %entry
  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
  %cmp.not = icmp eq i32 %i.0, 8
  br i1 %cmp.not, label %for.cond.cleanup, label %for.body

for.cond.cleanup:                                 ; preds = %for.cond
  %.fca.0.load = load i64, ptr %retval, align 2
  %.fca.0.insert = insertvalue { i64, i64 } poison, i64 %.fca.0.load, 0
  %.fca.1.gep = getelementptr inbounds nuw i8, ptr %retval, i64 8
  %.fca.1.load = load i64, ptr %.fca.1.gep, align 2
  %.fca.1.insert = insertvalue { i64, i64 } %.fca.0.insert, i64 %.fca.1.load, 1
  ret { i64, i64 } %.fca.1.insert

for.body:                                         ; preds = %for.cond
  %conv = zext nneg i32 %i.0 to i64
  %pt1 = getelementptr inbounds nuw [8 x i16], ptr %x, i64 0, i64 %conv
  %pt0 = getelementptr inbounds nuw [8 x i16], ptr %y, i64 0, i64 %conv
  %ld0 = load i16, ptr %pt0, align 2
  %ld1 = load i16, ptr %pt1, align 2
  %cmp.i = icmp slt i16 %ld0, %ld1
  %sel = select i1 %cmp.i, ptr %pt0, ptr %pt1
  %ld2 = load i16, ptr %sel, align 2
  %pt2 = getelementptr inbounds nuw [8 x i16], ptr %retval, i64 0, i64 %conv
  store i16 %ld2, ptr %pt2, align 2
  %inc = add nuw nsw i32 %i.0, 1
  br label %for.cond
}