1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
5 define i1 @test1(i32 *%x) nounwind {
8 ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint i32* [[X:%.*]] to i64
9 ; CHECK-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], 1
10 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i64 [[TMP1]], 0
11 ; CHECK-NEXT: ret i1 [[TMP2]]
14 %0 = ptrtoint i32* %x to i1
18 define i32* @test2(i128 %x) nounwind {
19 ; CHECK-LABEL: @test2(
21 ; CHECK-NEXT: [[TMP0:%.*]] = trunc i128 [[X:%.*]] to i64
22 ; CHECK-NEXT: [[TMP1:%.*]] = inttoptr i64 [[TMP0]] to i32*
23 ; CHECK-NEXT: ret i32* [[TMP1]]
26 %0 = inttoptr i128 %x to i32*
31 define i64 @f0(i32 %a0) nounwind {
33 ; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[A0:%.*]] to i64
34 ; CHECK-NEXT: ret i64 [[TMP1]]
36 %t0 = inttoptr i32 %a0 to i8*
37 %t1 = ptrtoint i8* %t0 to i64
41 define <4 x i32> @test4(<4 x i8*> %arg) nounwind {
42 ; CHECK-LABEL: @test4(
43 ; CHECK-NEXT: [[TMP1:%.*]] = ptrtoint <4 x i8*> [[ARG:%.*]] to <4 x i64>
44 ; CHECK-NEXT: [[P1:%.*]] = trunc <4 x i64> [[TMP1]] to <4 x i32>
45 ; CHECK-NEXT: ret <4 x i32> [[P1]]
47 %p1 = ptrtoint <4 x i8*> %arg to <4 x i32>
51 define <vscale x 4 x i32> @testvscale4(<vscale x 4 x i8*> %arg) nounwind {
52 ; CHECK-LABEL: @testvscale4(
53 ; CHECK-NEXT: [[TMP1:%.*]] = ptrtoint <vscale x 4 x i8*> [[ARG:%.*]] to <vscale x 4 x i64>
54 ; CHECK-NEXT: [[P1:%.*]] = trunc <vscale x 4 x i64> [[TMP1]] to <vscale x 4 x i32>
55 ; CHECK-NEXT: ret <vscale x 4 x i32> [[P1]]
57 %p1 = ptrtoint <vscale x 4 x i8*> %arg to <vscale x 4 x i32>
58 ret <vscale x 4 x i32> %p1
61 define <4 x i128> @test5(<4 x i8*> %arg) nounwind {
62 ; CHECK-LABEL: @test5(
63 ; CHECK-NEXT: [[TMP1:%.*]] = ptrtoint <4 x i8*> [[ARG:%.*]] to <4 x i64>
64 ; CHECK-NEXT: [[P1:%.*]] = zext <4 x i64> [[TMP1]] to <4 x i128>
65 ; CHECK-NEXT: ret <4 x i128> [[P1]]
67 %p1 = ptrtoint <4 x i8*> %arg to <4 x i128>
71 define <4 x i8*> @test6(<4 x i32> %arg) nounwind {
72 ; CHECK-LABEL: @test6(
73 ; CHECK-NEXT: [[TMP1:%.*]] = zext <4 x i32> [[ARG:%.*]] to <4 x i64>
74 ; CHECK-NEXT: [[P1:%.*]] = inttoptr <4 x i64> [[TMP1]] to <4 x i8*>
75 ; CHECK-NEXT: ret <4 x i8*> [[P1]]
77 %p1 = inttoptr <4 x i32> %arg to <4 x i8*>
81 define <4 x i8*> @test7(<4 x i128> %arg) nounwind {
82 ; CHECK-LABEL: @test7(
83 ; CHECK-NEXT: [[TMP1:%.*]] = trunc <4 x i128> [[ARG:%.*]] to <4 x i64>
84 ; CHECK-NEXT: [[P1:%.*]] = inttoptr <4 x i64> [[TMP1]] to <4 x i8*>
85 ; CHECK-NEXT: ret <4 x i8*> [[P1]]
87 %p1 = inttoptr <4 x i128> %arg to <4 x i8*>