1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=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(ptr %x) nounwind {
8 ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[X:%.*]] to i64
9 ; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[TMP0]] to i1
10 ; CHECK-NEXT: ret i1 [[TMP2]]
13 %0 = ptrtoint ptr %x to i1
17 define ptr @test2(i128 %x) nounwind {
18 ; CHECK-LABEL: @test2(
20 ; CHECK-NEXT: [[TMP0:%.*]] = trunc i128 [[X:%.*]] to i64
21 ; CHECK-NEXT: [[TMP1:%.*]] = inttoptr i64 [[TMP0]] to ptr
22 ; CHECK-NEXT: ret ptr [[TMP1]]
25 %0 = inttoptr i128 %x to ptr
30 define i64 @f0(i32 %a0) nounwind {
32 ; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[A0:%.*]] to i64
33 ; CHECK-NEXT: ret i64 [[TMP1]]
35 %t0 = inttoptr i32 %a0 to ptr
36 %t1 = ptrtoint ptr %t0 to i64
40 define <4 x i32> @test4(<4 x ptr> %arg) nounwind {
41 ; CHECK-LABEL: @test4(
42 ; CHECK-NEXT: [[TMP1:%.*]] = ptrtoint <4 x ptr> [[ARG:%.*]] to <4 x i64>
43 ; CHECK-NEXT: [[P1:%.*]] = trunc <4 x i64> [[TMP1]] to <4 x i32>
44 ; CHECK-NEXT: ret <4 x i32> [[P1]]
46 %p1 = ptrtoint <4 x ptr> %arg to <4 x i32>
50 define <vscale x 4 x i32> @testvscale4(<vscale x 4 x ptr> %arg) nounwind {
51 ; CHECK-LABEL: @testvscale4(
52 ; CHECK-NEXT: [[TMP1:%.*]] = ptrtoint <vscale x 4 x ptr> [[ARG:%.*]] to <vscale x 4 x i64>
53 ; CHECK-NEXT: [[P1:%.*]] = trunc <vscale x 4 x i64> [[TMP1]] to <vscale x 4 x i32>
54 ; CHECK-NEXT: ret <vscale x 4 x i32> [[P1]]
56 %p1 = ptrtoint <vscale x 4 x ptr> %arg to <vscale x 4 x i32>
57 ret <vscale x 4 x i32> %p1
60 define <4 x i128> @test5(<4 x ptr> %arg) nounwind {
61 ; CHECK-LABEL: @test5(
62 ; CHECK-NEXT: [[TMP1:%.*]] = ptrtoint <4 x ptr> [[ARG:%.*]] to <4 x i64>
63 ; CHECK-NEXT: [[P1:%.*]] = zext <4 x i64> [[TMP1]] to <4 x i128>
64 ; CHECK-NEXT: ret <4 x i128> [[P1]]
66 %p1 = ptrtoint <4 x ptr> %arg to <4 x i128>
70 define <4 x ptr> @test6(<4 x i32> %arg) nounwind {
71 ; CHECK-LABEL: @test6(
72 ; CHECK-NEXT: [[TMP1:%.*]] = zext <4 x i32> [[ARG:%.*]] to <4 x i64>
73 ; CHECK-NEXT: [[P1:%.*]] = inttoptr <4 x i64> [[TMP1]] to <4 x ptr>
74 ; CHECK-NEXT: ret <4 x ptr> [[P1]]
76 %p1 = inttoptr <4 x i32> %arg to <4 x ptr>
80 define <4 x ptr> @test7(<4 x i128> %arg) nounwind {
81 ; CHECK-LABEL: @test7(
82 ; CHECK-NEXT: [[TMP1:%.*]] = trunc <4 x i128> [[ARG:%.*]] to <4 x i64>
83 ; CHECK-NEXT: [[P1:%.*]] = inttoptr <4 x i64> [[TMP1]] to <4 x ptr>
84 ; CHECK-NEXT: ret <4 x ptr> [[P1]]
86 %p1 = inttoptr <4 x i128> %arg to <4 x ptr>