File: insert-ext.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (137 lines) | stat: -rw-r--r-- 5,020 bytes parent folder | download | duplicates (3)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s

declare void @use(i32)
declare void @usevec(<2 x i32>)

define <2 x double> @fpext_fpext(<2 x half> %x, half %y, i32 %index) {
; CHECK-LABEL: @fpext_fpext(
; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <2 x half> [[X:%.*]], half [[Y:%.*]], i32 [[INDEX:%.*]]
; CHECK-NEXT:    [[I:%.*]] = fpext <2 x half> [[TMP1]] to <2 x double>
; CHECK-NEXT:    ret <2 x double> [[I]]
;
  %v = fpext <2 x half> %x to <2 x double>
  %s = fpext half %y to double
  %i = insertelement <2 x double> %v, double %s, i32 %index
  ret <2 x double> %i
}

define <2 x i32> @sext_sext(<2 x i8> %x, i8 %y, i32 %index) {
; CHECK-LABEL: @sext_sext(
; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <2 x i8> [[X:%.*]], i8 [[Y:%.*]], i32 [[INDEX:%.*]]
; CHECK-NEXT:    [[I:%.*]] = sext <2 x i8> [[TMP1]] to <2 x i32>
; CHECK-NEXT:    ret <2 x i32> [[I]]
;
  %v = sext <2 x i8> %x to <2 x i32>
  %s = sext i8 %y to i32
  %i = insertelement <2 x i32> %v, i32 %s, i32 %index
  ret <2 x i32> %i
}

define <2 x i12> @zext_zext(<2 x i8> %x, i8 %y, i32 %index) {
; CHECK-LABEL: @zext_zext(
; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <2 x i8> [[X:%.*]], i8 [[Y:%.*]], i32 [[INDEX:%.*]]
; CHECK-NEXT:    [[I:%.*]] = zext <2 x i8> [[TMP1]] to <2 x i12>
; CHECK-NEXT:    ret <2 x i12> [[I]]
;
  %v = zext <2 x i8> %x to <2 x i12>
  %s = zext i8 %y to i12
  %i = insertelement <2 x i12> %v, i12 %s, i32 %index
  ret <2 x i12> %i
}

; negative test - need same source type

define <2 x double> @fpext_fpext_types(<2 x half> %x, float %y, i32 %index) {
; CHECK-LABEL: @fpext_fpext_types(
; CHECK-NEXT:    [[V:%.*]] = fpext <2 x half> [[X:%.*]] to <2 x double>
; CHECK-NEXT:    [[S:%.*]] = fpext float [[Y:%.*]] to double
; CHECK-NEXT:    [[I:%.*]] = insertelement <2 x double> [[V]], double [[S]], i32 [[INDEX:%.*]]
; CHECK-NEXT:    ret <2 x double> [[I]]
;
  %v = fpext <2 x half> %x to <2 x double>
  %s = fpext float %y to double
  %i = insertelement <2 x double> %v, double %s, i32 %index
  ret <2 x double> %i
}

; negative test - need same source type

define <2 x i32> @sext_sext_types(<2 x i16> %x, i8 %y, i32 %index) {
; CHECK-LABEL: @sext_sext_types(
; CHECK-NEXT:    [[V:%.*]] = sext <2 x i16> [[X:%.*]] to <2 x i32>
; CHECK-NEXT:    [[S:%.*]] = sext i8 [[Y:%.*]] to i32
; CHECK-NEXT:    [[I:%.*]] = insertelement <2 x i32> [[V]], i32 [[S]], i32 [[INDEX:%.*]]
; CHECK-NEXT:    ret <2 x i32> [[I]]
;
  %v = sext <2 x i16> %x to <2 x i32>
  %s = sext i8 %y to i32
  %i = insertelement <2 x i32> %v, i32 %s, i32 %index
  ret <2 x i32> %i
}

; negative test - need same extend opcode

define <2 x i12> @sext_zext(<2 x i8> %x, i8 %y, i32 %index) {
; CHECK-LABEL: @sext_zext(
; CHECK-NEXT:    [[V:%.*]] = sext <2 x i8> [[X:%.*]] to <2 x i12>
; CHECK-NEXT:    [[S:%.*]] = zext i8 [[Y:%.*]] to i12
; CHECK-NEXT:    [[I:%.*]] = insertelement <2 x i12> [[V]], i12 [[S]], i32 [[INDEX:%.*]]
; CHECK-NEXT:    ret <2 x i12> [[I]]
;
  %v = sext <2 x i8> %x to <2 x i12>
  %s = zext i8 %y to i12
  %i = insertelement <2 x i12> %v, i12 %s, i32 %index
  ret <2 x i12> %i
}

; negative test - don't trade scalar extend for vector extend

define <2 x i32> @sext_sext_use1(<2 x i8> %x, i8 %y, i32 %index) {
; CHECK-LABEL: @sext_sext_use1(
; CHECK-NEXT:    [[V:%.*]] = sext <2 x i8> [[X:%.*]] to <2 x i32>
; CHECK-NEXT:    call void @usevec(<2 x i32> [[V]])
; CHECK-NEXT:    [[S:%.*]] = sext i8 [[Y:%.*]] to i32
; CHECK-NEXT:    [[I:%.*]] = insertelement <2 x i32> [[V]], i32 [[S]], i32 [[INDEX:%.*]]
; CHECK-NEXT:    ret <2 x i32> [[I]]
;
  %v = sext <2 x i8> %x to <2 x i32>
  call void @usevec(<2 x i32> %v)
  %s = sext i8 %y to i32
  %i = insertelement <2 x i32> %v, i32 %s, i32 %index
  ret <2 x i32> %i
}

define <2 x i32> @zext_zext_use2(<2 x i8> %x, i8 %y, i32 %index) {
; CHECK-LABEL: @zext_zext_use2(
; CHECK-NEXT:    [[S:%.*]] = zext i8 [[Y:%.*]] to i32
; CHECK-NEXT:    call void @use(i32 [[S]])
; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <2 x i8> [[X:%.*]], i8 [[Y]], i32 [[INDEX:%.*]]
; CHECK-NEXT:    [[I:%.*]] = zext <2 x i8> [[TMP1]] to <2 x i32>
; CHECK-NEXT:    ret <2 x i32> [[I]]
;
  %v = zext <2 x i8> %x to <2 x i32>
  %s = zext i8 %y to i32
  call void @use(i32 %s)
  %i = insertelement <2 x i32> %v, i32 %s, i32 %index
  ret <2 x i32> %i
}

; negative test - don't create an extra extend

define <2 x i32> @zext_zext_use3(<2 x i8> %x, i8 %y, i32 %index) {
; CHECK-LABEL: @zext_zext_use3(
; CHECK-NEXT:    [[V:%.*]] = zext <2 x i8> [[X:%.*]] to <2 x i32>
; CHECK-NEXT:    call void @usevec(<2 x i32> [[V]])
; CHECK-NEXT:    [[S:%.*]] = zext i8 [[Y:%.*]] to i32
; CHECK-NEXT:    call void @use(i32 [[S]])
; CHECK-NEXT:    [[I:%.*]] = insertelement <2 x i32> [[V]], i32 [[S]], i32 [[INDEX:%.*]]
; CHECK-NEXT:    ret <2 x i32> [[I]]
;
  %v = zext <2 x i8> %x to <2 x i32>
  call void @usevec(<2 x i32> %v)
  %s = zext i8 %y to i32
  call void @use(i32 %s)
  %i = insertelement <2 x i32> %v, i32 %s, i32 %index
  ret <2 x i32> %i
}