1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instcombine -S < %s | FileCheck %s
4 target datalayout = "p:64:64:64-i64:32:32"
7 define ptr @test1(ptr %x) {
10 ; CHECK-NEXT: [[B:%.*]] = load i64, ptr [[X:%.*]], align 4
11 ; CHECK-NEXT: [[C:%.*]] = inttoptr i64 [[B]] to ptr
12 ; CHECK-NEXT: ret ptr [[C]]
16 %c = inttoptr i64 %b to ptr
21 define ptr @test2(ptr %x) {
22 ; CHECK-LABEL: @test2(
24 ; CHECK-NEXT: [[B:%.*]] = load i32, ptr [[X:%.*]], align 4
25 ; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[B]] to i64
26 ; CHECK-NEXT: [[C:%.*]] = inttoptr i64 [[TMP0]] to ptr
27 ; CHECK-NEXT: ret ptr [[C]]
31 %c = inttoptr i32 %b to ptr
36 define ptr @test3(ptr %x) {
37 ; CHECK-LABEL: @test3(
39 ; CHECK-NEXT: [[B:%.*]] = load i32, ptr [[X:%.*]], align 4
40 ; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[B]] to i64
41 ; CHECK-NEXT: [[C:%.*]] = inttoptr i64 [[TMP0]] to ptr
42 ; CHECK-NEXT: ret ptr [[C]]
46 %c = inttoptr i32 %b to ptr
51 define i64 @test4(ptr %x) {
52 ; CHECK-LABEL: @test4(
54 ; CHECK-NEXT: [[B:%.*]] = load ptr, ptr [[X:%.*]], align 8
55 ; CHECK-NEXT: [[C:%.*]] = ptrtoint ptr [[B]] to i64
56 ; CHECK-NEXT: ret i64 [[C]]
60 %c = ptrtoint ptr %b to i64
65 define i32 @test5(ptr %x) {
66 ; CHECK-LABEL: @test5(
68 ; CHECK-NEXT: [[B:%.*]] = load ptr, ptr [[X:%.*]], align 8
69 ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[B]] to i64
70 ; CHECK-NEXT: [[C:%.*]] = trunc i64 [[TMP0]] to i32
71 ; CHECK-NEXT: ret i32 [[C]]
75 %c = ptrtoint ptr %b to i32
80 define i64 @test6(ptr %x) {
81 ; CHECK-LABEL: @test6(
83 ; CHECK-NEXT: [[B:%.*]] = load ptr, ptr [[X:%.*]], align 8
84 ; CHECK-NEXT: [[C:%.*]] = ptrtoint ptr [[B]] to i64
85 ; CHECK-NEXT: ret i64 [[C]]
89 %c = ptrtoint ptr %b to i64