Home | History | Annotate | Download | only in InstCombine
      1 ; RUN: opt -instcombine -S < %s | FileCheck %s
      2 
      3 target datalayout = "p:64:64:64"
      4 
      5 
      6 define i64* @test1(i8* %x) {
      7 entry:
      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 
     18 define i32* @test2(i8* %x) {
     19 entry:
     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 
     30 define i64* @test3(i8* %x) {
     31 entry:
     32 ; CHECK-LABEL: @test3(
     33 ; CHECK: load i32, i32*
     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 
     42 define i64 @test4(i8* %x) {
     43 entry:
     44 ; CHECK-LABEL: @test4(
     45 ; CHECK: load i64, i64*
     46 ; CHECK: ret
     47   %a = bitcast i8* %x to i64**
     48   %b = load i64*, i64** %a
     49   %c = ptrtoint i64* %b to i64
     50 
     51   ret i64 %c
     52 }
     53 
     54 define i32 @test5(i8* %x) {
     55 entry:
     56 ; CHECK-LABEL: @test5(
     57 ; CHECK: load i64, i64*
     58 ; CHECK: trunc
     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 
     67 define i64 @test6(i8* %x) {
     68 entry:
     69 ; CHECK-LABEL: @test6(
     70 ; CHECK: load i64, i64*
     71 ; CHECK: ret
     72   %a = bitcast i8* %x to i32**
     73   %b = load i32*, i32** %a
     74   %c = ptrtoint i32* %b to i64
     75 
     76   ret i64 %c
     77 }
     78 
     79