aboutsummaryrefslogtreecommitdiff
path: root/test/Transforms/ConstProp/extractvalue.ll
blob: 32d529181b1f00bd8163ae306ea8cc83ccbe9a98 (plain) (blame)
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
; RUN: opt < %s -constprop -S | FileCheck %s

%struct = type { i32, [4 x i8] }
%array = type [3 x %struct]

define i32 @test1() {
  %A = extractvalue %struct { i32 2, [4 x i8] c"foo\00" }, 0
  ret i32 %A
; CHECK: @test1
; CHECK: ret i32 2
}

define i8 @test2() {
  %A = extractvalue %struct { i32 2, [4 x i8] c"foo\00" }, 1, 2
  ret i8 %A
; CHECK: @test2
; CHECK: ret i8 111
}

define i32 @test3() {
  %A = extractvalue %array [ %struct { i32 0, [4 x i8] c"aaaa" }, %struct { i32 1, [4 x i8] c"bbbb" }, %struct { i32 2, [4 x i8] c"cccc" } ], 1, 0
  ret i32 %A
; CHECK: @test3
; CHECK: ret i32 1
}

define i32 @zeroinitializer-test1() {
  %A = extractvalue %struct zeroinitializer, 0
  ret i32 %A
; CHECK: @zeroinitializer-test1
; CHECK: ret i32 0
}

define i8 @zeroinitializer-test2() {
  %A = extractvalue %struct zeroinitializer, 1, 2
  ret i8 %A
; CHECK: @zeroinitializer-test2
; CHECK: ret i8 0
}

define i32 @zeroinitializer-test3() {
  %A = extractvalue %array zeroinitializer, 1, 0
  ret i32 %A
; CHECK: @zeroinitializer-test3
; CHECK: ret i32 0
}

define i32 @undef-test1() {
  %A = extractvalue %struct undef, 0
  ret i32 %A
; CHECK: @undef-test1
; CHECK: ret i32 undef
}

define i8 @undef-test2() {
  %A = extractvalue %struct undef, 1, 2
  ret i8 %A
; CHECK: @undef-test2
; CHECK: ret i8 undef
}

define i32 @undef-test3() {
  %A = extractvalue %array undef, 1, 0
  ret i32 %A
; CHECK: @undef-test3
; CHECK: ret i32 undef
}