blob: b1c78a8a314eb8d58e9269142fbc4e89856d9492 [file] [log] [blame]
Quentin Colombet490cfbe2016-02-11 22:30:41 +00001; RUN: opt -instcombine -S < %s | FileCheck %s
2
3target datalayout = "p:32:32:32"
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 i64*, i64**
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 i32, i32*
46; CHECK: zext
47; CHECK: ret
48 %a = bitcast i8* %x to i64**
49 %b = load i64*, i64** %a
50 %c = ptrtoint i64* %b to i64
51
52 ret i64 %c
53}
54
55define i32 @test5(i8* %x) {
56entry:
57; CHECK-LABEL: @test5(
58; CHECK: load i32, i32*
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 i32, i32*
71; CHECK: zext
72; CHECK: ret
73 %a = bitcast i8* %x to i32**
74 %b = load i32*, i32** %a
75 %c = ptrtoint i32* %b to i64
76
77 ret i64 %c
78}
79