1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -instcombine -S < %s | FileCheck %s
4 target datalayout = "p:64:64:64-i64:32:32"
7 define i64* @test1(i8* %x) {
10 ; CHECK-NEXT: [[A:%.*]] = bitcast i8* [[X:%.*]] to i64*
11 ; CHECK-NEXT: [[B:%.*]] = load i64, i64* [[A]], align 4
12 ; CHECK-NEXT: [[C:%.*]] = inttoptr i64 [[B]] to i64*
13 ; CHECK-NEXT: ret i64* [[C]]
16 %a = bitcast i8* %x to i64*
17 %b = load i64, i64* %a
18 %c = inttoptr i64 %b to i64*
23 define i32* @test2(i8* %x) {
24 ; CHECK-LABEL: @test2(
26 ; CHECK-NEXT: [[A:%.*]] = bitcast i8* [[X:%.*]] to i32*
27 ; CHECK-NEXT: [[B:%.*]] = load i32, i32* [[A]], align 4
28 ; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[B]] to i64
29 ; CHECK-NEXT: [[C:%.*]] = inttoptr i64 [[TMP0]] to i32*
30 ; CHECK-NEXT: ret i32* [[C]]
33 %a = bitcast i8* %x to i32*
34 %b = load i32, i32* %a
35 %c = inttoptr i32 %b to i32*
40 define i64* @test3(i8* %x) {
41 ; CHECK-LABEL: @test3(
43 ; CHECK-NEXT: [[A:%.*]] = bitcast i8* [[X:%.*]] to i32*
44 ; CHECK-NEXT: [[B:%.*]] = load i32, i32* [[A]], align 4
45 ; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[B]] to i64
46 ; CHECK-NEXT: [[C:%.*]] = inttoptr i64 [[TMP0]] to i64*
47 ; CHECK-NEXT: ret i64* [[C]]
50 %a = bitcast i8* %x to i32*
51 %b = load i32, i32* %a
52 %c = inttoptr i32 %b to i64*
57 define i64 @test4(i8* %x) {
58 ; CHECK-LABEL: @test4(
60 ; CHECK-NEXT: [[A:%.*]] = bitcast i8* [[X:%.*]] to i64**
61 ; CHECK-NEXT: [[B:%.*]] = load i64*, i64** [[A]], align 8
62 ; CHECK-NEXT: [[C:%.*]] = ptrtoint i64* [[B]] to i64
63 ; CHECK-NEXT: ret i64 [[C]]
66 %a = bitcast i8* %x to i64**
67 %b = load i64*, i64** %a
68 %c = ptrtoint i64* %b to i64
73 define i32 @test5(i8* %x) {
74 ; CHECK-LABEL: @test5(
76 ; CHECK-NEXT: [[A:%.*]] = bitcast i8* [[X:%.*]] to i32**
77 ; CHECK-NEXT: [[B:%.*]] = load i32*, i32** [[A]], align 8
78 ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint i32* [[B]] to i64
79 ; CHECK-NEXT: [[C:%.*]] = trunc i64 [[TMP0]] to i32
80 ; CHECK-NEXT: ret i32 [[C]]
83 %a = bitcast i8* %x to i32**
84 %b = load i32*, i32** %a
85 %c = ptrtoint i32* %b to i32
90 define i64 @test6(i8* %x) {
91 ; CHECK-LABEL: @test6(
93 ; CHECK-NEXT: [[A:%.*]] = bitcast i8* [[X:%.*]] to i32**
94 ; CHECK-NEXT: [[B:%.*]] = load i32*, i32** [[A]], align 8
95 ; CHECK-NEXT: [[C:%.*]] = ptrtoint i32* [[B]] to i64
96 ; CHECK-NEXT: ret i64 [[C]]
99 %a = bitcast i8* %x to i32**
100 %b = load i32*, i32** %a
101 %c = ptrtoint i32* %b to i64