aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/Transforms/InstSimplify/insertvalue.ll
blob: 441ced274ddc8cdef239386696e20271cd4ea8e1 (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 < %s -passes=instsimplify -S | FileCheck %s

define {i32, i32} @insert_poison({i32, i32} %x) {
; CHECK-LABEL: @insert_poison(
; CHECK-NEXT:    ret { i32, i32 } [[X:%.*]]
;
  %v = insertvalue {i32, i32} %x, i32 poison, 0
  ret {i32, i32} %v
}

define {i32, i32} @insert_undef({i32, i32} %x) {
; CHECK-LABEL: @insert_undef(
; CHECK-NEXT:    [[V:%.*]] = insertvalue { i32, i32 } [[X:%.*]], i32 undef, 0
; CHECK-NEXT:    ret { i32, i32 } [[V]]
;
  %v = insertvalue {i32, i32} %x, i32 undef, 0
  ret {i32, i32} %v
}

define {i32, i32} @insert_undef_into_non_poison({i32, i32} noundef %x) {
; CHECK-LABEL: @insert_undef_into_non_poison(
; CHECK-NEXT:    ret { i32, i32 } [[X:%.*]]
;
  %v = insertvalue {i32, i32} %x, i32 undef, 0
  ret {i32, i32} %v
}

define {i32, i32} @insert_into_poison({i32, i32} %x) {
; CHECK-LABEL: @insert_into_poison(
; CHECK-NEXT:    ret { i32, i32 } [[X:%.*]]
;
  %elem = extractvalue {i32, i32} %x, 0
  %v = insertvalue {i32, i32} poison, i32 %elem, 0
  ret {i32, i32} %v
}

define {i32, i32} @insert_into_undef({i32, i32} %x) {
; CHECK-LABEL: @insert_into_undef(
; CHECK-NEXT:    [[ELEM:%.*]] = extractvalue { i32, i32 } [[X:%.*]], 0
; CHECK-NEXT:    [[V:%.*]] = insertvalue { i32, i32 } undef, i32 [[ELEM]], 0
; CHECK-NEXT:    ret { i32, i32 } [[V]]
;
  %elem = extractvalue {i32, i32} %x, 0
  %v = insertvalue {i32, i32} undef, i32 %elem, 0
  ret {i32, i32} %v
}

define {i32, i32} @insert_non_poison_into_undef({i32, i32} noundef %x) {
; CHECK-LABEL: @insert_non_poison_into_undef(
; CHECK-NEXT:    ret { i32, i32 } [[X:%.*]]
;
  %elem = extractvalue {i32, i32} %x, 0
  %v = insertvalue {i32, i32} undef, i32 %elem, 0
  ret {i32, i32} %v
}