1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -instcombine -S < %s | FileCheck %s 3 4target datalayout = "p:64:64:64-i64:32:32" 5 6 7define i64* @test1(i8* %x) { 8; CHECK-LABEL: @test1( 9; CHECK-NEXT: entry: 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]] 14; 15entry: 16 %a = bitcast i8* %x to i64* 17 %b = load i64, i64* %a 18 %c = inttoptr i64 %b to i64* 19 20 ret i64* %c 21} 22 23define i32* @test2(i8* %x) { 24; CHECK-LABEL: @test2( 25; CHECK-NEXT: entry: 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]] 31; 32entry: 33 %a = bitcast i8* %x to i32* 34 %b = load i32, i32* %a 35 %c = inttoptr i32 %b to i32* 36 37 ret i32* %c 38} 39 40define i64* @test3(i8* %x) { 41; CHECK-LABEL: @test3( 42; CHECK-NEXT: entry: 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]] 48; 49entry: 50 %a = bitcast i8* %x to i32* 51 %b = load i32, i32* %a 52 %c = inttoptr i32 %b to i64* 53 54 ret i64* %c 55} 56 57define i64 @test4(i8* %x) { 58; CHECK-LABEL: @test4( 59; CHECK-NEXT: entry: 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]] 64; 65entry: 66 %a = bitcast i8* %x to i64** 67 %b = load i64*, i64** %a 68 %c = ptrtoint i64* %b to i64 69 70 ret i64 %c 71} 72 73define i32 @test5(i8* %x) { 74; CHECK-LABEL: @test5( 75; CHECK-NEXT: entry: 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]] 81; 82entry: 83 %a = bitcast i8* %x to i32** 84 %b = load i32*, i32** %a 85 %c = ptrtoint i32* %b to i32 86 87 ret i32 %c 88} 89 90define i64 @test6(i8* %x) { 91; CHECK-LABEL: @test6( 92; CHECK-NEXT: entry: 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]] 97; 98entry: 99 %a = bitcast i8* %x to i32** 100 %b = load i32*, i32** %a 101 %c = ptrtoint i32* %b to i64 102 103 ret i64 %c 104} 105 106