File: insertelement.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (72 lines) | stat: -rw-r--r-- 2,642 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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=instcombine -S | FileCheck %s

define <4 x i32> @insert_known_idx(<4 x i32> %x) {
; CHECK-LABEL: @insert_known_idx(
; CHECK-NEXT:    [[V1:%.*]] = and <4 x i32> [[X:%.*]], <i32 poison, i32 7, i32 7, i32 7>
; CHECK-NEXT:    [[V2:%.*]] = insertelement <4 x i32> [[V1]], i32 6, i64 0
; CHECK-NEXT:    ret <4 x i32> [[V2]]
;
  %v1 = and <4 x i32> %x, <i32 7, i32 7, i32 7, i32 7>
  %v2 = insertelement <4 x i32> %v1, i32 6, i32 0
  %v3 = and <4 x i32> %v2, <i32 7, i32 7, i32 7, i32 7>
  ret <4 x i32> %v3
}

define <4 x i32> @insert_unknown_idx(<4 x i32> %x, i32 %idx) {
; CHECK-LABEL: @insert_unknown_idx(
; CHECK-NEXT:    [[V1:%.*]] = and <4 x i32> [[X:%.*]], <i32 7, i32 7, i32 7, i32 7>
; CHECK-NEXT:    [[V2:%.*]] = insertelement <4 x i32> [[V1]], i32 6, i32 [[IDX:%.*]]
; CHECK-NEXT:    ret <4 x i32> [[V2]]
;
  %v1 = and <4 x i32> %x, <i32 7, i32 7, i32 7, i32 7>
  %v2 = insertelement <4 x i32> %v1, i32 6, i32 %idx
  %v3 = and <4 x i32> %v2, <i32 7, i32 7, i32 7, i32 7>
  ret <4 x i32> %v3
}

define <2 x i8> @insert_known_any_idx(<2 x i8> %xx, i8 %yy, i32 %idx) {
; CHECK-LABEL: @insert_known_any_idx(
; CHECK-NEXT:    ret <2 x i8> <i8 16, i8 16>
;
  %x = or <2 x i8> %xx, <i8 16, i8 16>
  %y = or i8 %yy, 16

  %ins = insertelement <2 x i8> %x, i8 %y, i32 %idx
  %r = and <2 x i8> %ins, <i8 16, i8 16>
  ret <2 x i8> %r
}

define <2 x i8> @insert_known_any_idx_fail1(<2 x i8> %xx, i8 %yy, i32 %idx) {
; CHECK-LABEL: @insert_known_any_idx_fail1(
; CHECK-NEXT:    [[X:%.*]] = or <2 x i8> [[XX:%.*]], <i8 17, i8 33>
; CHECK-NEXT:    [[Y:%.*]] = or i8 [[YY:%.*]], 16
; CHECK-NEXT:    [[INS:%.*]] = insertelement <2 x i8> [[X]], i8 [[Y]], i32 [[IDX:%.*]]
; CHECK-NEXT:    [[R:%.*]] = and <2 x i8> [[INS]], <i8 16, i8 16>
; CHECK-NEXT:    ret <2 x i8> [[R]]
;
  %x = or <2 x i8> %xx, <i8 17, i8 33>
  %y = or i8 %yy, 16

  %ins = insertelement <2 x i8> %x, i8 %y, i32 %idx
  %r = and <2 x i8> %ins, <i8 16, i8 16>
  ret <2 x i8> %r
}


define <2 x i8> @insert_known_any_idx_fail2(<2 x i8> %xx, i8 %yy, i32 %idx) {
; CHECK-LABEL: @insert_known_any_idx_fail2(
; CHECK-NEXT:    [[X:%.*]] = or <2 x i8> [[XX:%.*]], <i8 17, i8 31>
; CHECK-NEXT:    [[Y:%.*]] = or i8 [[YY:%.*]], 15
; CHECK-NEXT:    [[INS:%.*]] = insertelement <2 x i8> [[X]], i8 [[Y]], i32 [[IDX:%.*]]
; CHECK-NEXT:    [[R:%.*]] = and <2 x i8> [[INS]], <i8 16, i8 16>
; CHECK-NEXT:    ret <2 x i8> [[R]]
;
  %x = or <2 x i8> %xx, <i8 17, i8 31>
  %y = or i8 %yy, 15

  %ins = insertelement <2 x i8> %x, i8 %y, i32 %idx
  %r = and <2 x i8> %ins, <i8 16, i8 16>
  ret <2 x i8> %r
}