1 # RUN: llc -mtriple arm-- -run-pass=legalizer %s -o - | FileCheck %s
2 # RUN: llc -mtriple thumb-- -mattr=+v6t2 -run-pass=legalizer %s -o - | FileCheck %s
4 define void @test_inttoptr_s32() { ret void }
5 define void @test_ptrtoint_s32() { ret void }
7 define void @test_inttoptr_s16() { ret void }
8 define void @test_ptrtoint_s8() { ret void }
11 name: test_inttoptr_s32
12 # CHECK-LABEL: name: test_inttoptr_s32
14 # CHECK: legalized: true
15 regBankSelected: false
17 tracksRegLiveness: true
26 %1(p0) = G_INTTOPTR %0(s32)
27 ; G_INTTOPTR with s32 is legal, so we should find it unchanged in the output
28 ; CHECK: {{%[0-9]+}}:_(p0) = G_INTTOPTR {{%[0-9]+}}
30 BX_RET 14, $noreg, implicit $r0
33 name: test_ptrtoint_s32
34 # CHECK-LABEL: name: test_ptrtoint_s32
36 # CHECK: legalized: true
37 regBankSelected: false
39 tracksRegLiveness: true
48 %1(s32) = G_PTRTOINT %0(p0)
49 ; G_PTRTOINT with s32 is legal, so we should find it unchanged in the output
50 ; CHECK: {{%[0-9]+}}:_(s32) = G_PTRTOINT {{%[0-9]+}}
52 BX_RET 14, $noreg, implicit $r0
55 name: test_inttoptr_s16
56 # CHECK-LABEL: name: test_inttoptr_s16
58 # CHECK: legalized: true
59 regBankSelected: false
61 tracksRegLiveness: true
71 %1(s16) = G_TRUNC %0(s32)
72 %2(p0) = G_INTTOPTR %1(s16)
73 ; G_INTTOPTR with s16 should zero extend
74 ; CHECK-NOT: G_INTTOPTR {{%[0-9]+}}(s16)
75 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
76 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_AND {{%[0-9]+}}, [[BITS]]
77 ; CHECK: {{%[0-9]+}}:_(p0) = G_INTTOPTR [[X32]](s32)
78 ; CHECK-NOT: G_INTTOPTR {{%[0-9]+}}(s16)
80 BX_RET 14, $noreg, implicit $r0
83 name: test_ptrtoint_s8
84 # CHECK-LABEL: name: test_ptrtoint_s8
86 # CHECK: legalized: true
87 regBankSelected: false
89 tracksRegLiveness: true
99 %1(s8) = G_PTRTOINT %0(p0)
100 ; G_PTRTOINT with s8 should truncate
101 ; CHECK-NOT: {{%[0-9]+}}(s8) = G_PTRTOINT
102 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_PTRTOINT {{%[0-9]+}}(p0)
103 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
104 ; CHECK: {{%[0-9]+}}:_(s32) = G_AND [[X32]], [[BITS]]
105 ; CHECK-NOT: {{%[0-9]+}}(s8) = G_PTRTOINT
106 %2(s32) = G_ZEXT %1(s8)
108 BX_RET 14, $noreg, implicit $r0