comparison test/Transforms/InstCombine/cast_ptr.ll @ 83:60c9769439b8 LLVM3.7

LLVM 3.7
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Wed, 18 Feb 2015 14:55:36 +0900
parents 95c75e76d11b
children afa8332a0e37
comparison
equal deleted inserted replaced
78:af83660cff7b 83:60c9769439b8
1 ; Tests to make sure elimination of casts is working correctly 1 ; Tests to make sure elimination of casts is working correctly
2 ; RUN: opt < %s -instcombine -S | FileCheck %s 2 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 3
4 target datalayout = "p:32:32-p1:32:32-p2:16:16" 4 target datalayout = "p:32:32-p1:32:32-p2:16:16"
5
6 @global = global i8 0
5 7
6 ; This shouldn't convert to getelementptr because the relationship 8 ; This shouldn't convert to getelementptr because the relationship
7 ; between the arithmetic and the layout of allocated memory is 9 ; between the arithmetic and the layout of allocated memory is
8 ; entirely unknown. 10 ; entirely unknown.
9 ; CHECK-LABEL: @test1( 11 ; CHECK-LABEL: @test1(
45 %tmpb = ptrtoint i8 addrspace(2)* %b to i32 47 %tmpb = ptrtoint i8 addrspace(2)* %b to i32
46 %r = icmp eq i32 %tmpa, %tmpb 48 %r = icmp eq i32 %tmpa, %tmpb
47 ret i1 %r 49 ret i1 %r
48 } 50 }
49 51
52 ; These casts should not be folded away.
53 ; CHECK-LABEL: @test2_diff_as
54 ; CHECK: icmp sge i32 %i0, %i1
55 define i1 @test2_diff_as(i8* %p, i8 addrspace(1)* %q) {
56 %i0 = ptrtoint i8* %p to i32
57 %i1 = ptrtoint i8 addrspace(1)* %q to i32
58 %r0 = icmp sge i32 %i0, %i1
59 ret i1 %r0
60 }
61
62 ; These casts should not be folded away.
63 ; CHECK-LABEL: @test2_diff_as_global
64 ; CHECK: icmp sge i32 %i1
65 define i1 @test2_diff_as_global(i8 addrspace(1)* %q) {
66 %i0 = ptrtoint i8* @global to i32
67 %i1 = ptrtoint i8 addrspace(1)* %q to i32
68 %r0 = icmp sge i32 %i1, %i0
69 ret i1 %r0
70 }
71
50 ; These casts should also be folded away. 72 ; These casts should also be folded away.
51 ; CHECK-LABEL: @test3( 73 ; CHECK-LABEL: @test3(
52 ; CHECK: icmp eq i8* %a, @global 74 ; CHECK: icmp eq i8* %a, @global
53 @global = global i8 0
54 define i1 @test3(i8* %a) { 75 define i1 @test3(i8* %a) {
55 %tmpa = ptrtoint i8* %a to i32 76 %tmpa = ptrtoint i8* %a to i32
56 %r = icmp eq i32 %tmpa, ptrtoint (i8* @global to i32) 77 %r = icmp eq i32 %tmpa, ptrtoint (i8* @global to i32)
57 ret i1 %r 78 ret i1 %r
58 } 79 }