1; RUN: opt -S -instsimplify < %s | FileCheck %s
2target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
3
4%mst = type { i8*, i8* }
5%mst2 = type { i32*, i32*, i32*, i32* }
6
7@a = private unnamed_addr constant %mst { i8* inttoptr (i64 -1 to i8*),
8                                          i8* inttoptr (i64 -1 to i8*)},
9                                          align 8
10@b = private unnamed_addr constant %mst2 { i32* inttoptr (i64 42 to i32*),
11                                           i32* inttoptr (i64 67 to i32*),
12                                           i32* inttoptr (i64 33 to i32*),
13                                           i32* inttoptr (i64 58 to i32*)},
14                                          align 8
15
16define i64 @fn() {
17  %x = load <2 x i8*>, <2 x i8*>* bitcast (%mst* @a to <2 x i8*>*), align 8
18  %b = extractelement <2 x i8*> %x, i32 0
19  %c = ptrtoint i8* %b to i64
20  ; CHECK-LABEL: @fn
21  ; CHECK-NEXT: ret i64 -1
22  ret i64 %c
23}
24
25define i64 @fn2() {
26  %x = load <4 x i32*>, <4 x i32*>* bitcast (%mst2* @b to <4 x i32*>*), align 8
27  %b = extractelement <4 x i32*> %x, i32 0
28  %c = extractelement <4 x i32*> %x, i32 3
29  %d = ptrtoint i32* %b to i64
30  %e = ptrtoint i32* %c to i64
31  %r = add i64 %d, %e
32  ; CHECK-LABEL: @fn2
33  ; CHECK-NEXT: ret i64 100
34  ret i64 %r
35}
36