1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -instcombine -S < %s | FileCheck %s
4 target datalayout = "p:32: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: [[TMP0:%.*]] = trunc i64 [[B]] to i32
13 ; CHECK-NEXT: [[C:%.*]] = inttoptr i32 [[TMP0]] to i64*
14 ; CHECK-NEXT: ret i64* [[C]]
17 %a = bitcast i8* %x to i64*
18 %b = load i64, i64* %a
19 %c = inttoptr i64 %b to i64*
24 define i32* @test2(i8* %x) {
25 ; CHECK-LABEL: @test2(
27 ; CHECK-NEXT: [[A:%.*]] = bitcast i8* [[X:%.*]] to i32*
28 ; CHECK-NEXT: [[B:%.*]] = load i32, i32* [[A]], align 4
29 ; CHECK-NEXT: [[C:%.*]] = inttoptr i32 [[B]] 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: [[C:%.*]] = inttoptr i32 [[B]] to i64*
46 ; CHECK-NEXT: ret i64* [[C]]
49 %a = bitcast i8* %x to i32*
50 %b = load i32, i32* %a
51 %c = inttoptr i32 %b to i64*
56 define i64 @test4(i8* %x) {
57 ; CHECK-LABEL: @test4(
59 ; CHECK-NEXT: [[A:%.*]] = bitcast i8* [[X:%.*]] to i64**
60 ; CHECK-NEXT: [[B:%.*]] = load i64*, i64** [[A]], align 4
61 ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint i64* [[B]] to i32
62 ; CHECK-NEXT: [[C:%.*]] = zext i32 [[TMP0]] 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 4
78 ; CHECK-NEXT: [[C:%.*]] = ptrtoint i32* [[B]] to i32
79 ; CHECK-NEXT: ret i32 [[C]]
82 %a = bitcast i8* %x to i32**
83 %b = load i32*, i32** %a
84 %c = ptrtoint i32* %b to i32
89 define i64 @test6(i8* %x) {
90 ; CHECK-LABEL: @test6(
92 ; CHECK-NEXT: [[A:%.*]] = bitcast i8* [[X:%.*]] to i32**
93 ; CHECK-NEXT: [[B:%.*]] = load i32*, i32** [[A]], align 4
94 ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint i32* [[B]] to i32
95 ; CHECK-NEXT: [[C:%.*]] = zext i32 [[TMP0]] 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