blob: d14c686d83ea3bed641c73980d4ad6deb0ecec85 [file] [log] [blame]
Quentin Colombet490cfbe2016-02-11 22:30:41 +00001; RUN: opt -instcombine -S < %s | FileCheck %s
2
3target datalayout = "p:64:64:64"
4
5
6define i64* @test1(i8* %x) {
7entry:
8; CHECK-LABEL: @test1(
9; CHECK: load i64*, i64**
10; CHECK: ret
11 %a = bitcast i8* %x to i64*
12 %b = load i64, i64* %a
13 %c = inttoptr i64 %b to i64*
14
15 ret i64* %c
16}
17
18define i32* @test2(i8* %x) {
19entry:
20; CHECK-LABEL: @test2(
21; CHECK: load i32, i32*
22; CHECK: ret
23 %a = bitcast i8* %x to i32*
24 %b = load i32, i32* %a
25 %c = inttoptr i32 %b to i32*
26
27 ret i32* %c
28}
29
30define i64* @test3(i8* %x) {
31entry:
32; CHECK-LABEL: @test3(
33; CHECK: load i32, i32*
34; CHECK: ret
35 %a = bitcast i8* %x to i32*
36 %b = load i32, i32* %a
37 %c = inttoptr i32 %b to i64*
38
39 ret i64* %c
40}
41
42define i64 @test4(i8* %x) {
43entry:
44; CHECK-LABEL: @test4(
45; CHECK: load i64, i64*
46; CHECK: ret
47 %a = bitcast i8* %x to i64**
48 %b = load i64*, i64** %a
49 %c = ptrtoint i64* %b to i64
50
51 ret i64 %c
52}
53
54define i32 @test5(i8* %x) {
55entry:
56; CHECK-LABEL: @test5(
57; CHECK: load i64, i64*
58; CHECK: trunc
59; CHECK: ret
60 %a = bitcast i8* %x to i32**
61 %b = load i32*, i32** %a
62 %c = ptrtoint i32* %b to i32
63
64 ret i32 %c
65}
66
67define i64 @test6(i8* %x) {
68entry:
69; CHECK-LABEL: @test6(
70; CHECK: load i64, i64*
71; CHECK: ret
72 %a = bitcast i8* %x to i32**
73 %b = load i32*, i32** %a
74 %c = ptrtoint i32* %b to i64
75
76 ret i64 %c
77}
78