1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -instcombine < %s | FileCheck %s
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6 ; Positive test - all uses are identical casts.
7 define void @t0(i1 zeroext %c0, i1 zeroext %c1, i64* nocapture readonly %src) {
10 ; CHECK-NEXT: [[DATA:%.*]] = load i64, i64* [[SRC:%.*]], align 8
11 ; CHECK-NEXT: br i1 [[C0:%.*]], label [[BB3:%.*]], label [[BB7:%.*]]
13 ; CHECK-NEXT: br i1 [[C1:%.*]], label [[BB4:%.*]], label [[BB5:%.*]]
15 ; CHECK-NEXT: tail call void @abort()
16 ; CHECK-NEXT: unreachable
18 ; CHECK-NEXT: [[PTR0:%.*]] = inttoptr i64 [[DATA]] to i32*
19 ; CHECK-NEXT: tail call void @sink0(i32* [[PTR0]])
20 ; CHECK-NEXT: br label [[BB9:%.*]]
22 ; CHECK-NEXT: [[PTR1:%.*]] = inttoptr i64 [[DATA]] to i32*
23 ; CHECK-NEXT: tail call void @sink1(i32* [[PTR1]])
24 ; CHECK-NEXT: br label [[BB9]]
26 ; CHECK-NEXT: ret void
29 %data = load i64, i64* %src, align 8
30 br i1 %c0, label %bb3, label %bb7
33 br i1 %c1, label %bb4, label %bb5
36 tail call void @abort()
40 %ptr0 = inttoptr i64 %data to i32*
41 tail call void @sink0(i32* %ptr0)
45 %ptr1 = inttoptr i64 %data to i32*
46 tail call void @sink1(i32* %ptr1)
53 ; Negative test - all uses are casts, but non-identical ones.
54 define void @n1(i1 zeroext %c0, i1 zeroext %c1, i64* nocapture readonly %src) {
57 ; CHECK-NEXT: [[DATA:%.*]] = load i64, i64* [[SRC:%.*]], align 8
58 ; CHECK-NEXT: br i1 [[C0:%.*]], label [[BB3:%.*]], label [[BB7:%.*]]
60 ; CHECK-NEXT: br i1 [[C1:%.*]], label [[BB4:%.*]], label [[BB5:%.*]]
62 ; CHECK-NEXT: tail call void @abort()
63 ; CHECK-NEXT: unreachable
65 ; CHECK-NEXT: [[PTR0:%.*]] = inttoptr i64 [[DATA]] to i32*
66 ; CHECK-NEXT: tail call void @sink0(i32* [[PTR0]])
67 ; CHECK-NEXT: br label [[BB9:%.*]]
69 ; CHECK-NEXT: [[VEC:%.*]] = bitcast i64 [[DATA]] to <2 x i32>
70 ; CHECK-NEXT: tail call void @sink2(<2 x i32> [[VEC]])
71 ; CHECK-NEXT: br label [[BB9]]
73 ; CHECK-NEXT: ret void
76 %data = load i64, i64* %src, align 8
77 br i1 %c0, label %bb3, label %bb7
80 br i1 %c1, label %bb4, label %bb5
83 tail call void @abort()
87 %ptr0 = inttoptr i64 %data to i32*
88 tail call void @sink0(i32* %ptr0)
92 %vec = bitcast i64 %data to <2 x i32> ; different cast
93 tail call void @sink2(<2 x i32> %vec)
100 ; Negative test - have non-cast users.
101 define void @n2(i1 zeroext %c0, i1 zeroext %c1, i64* nocapture readonly %src) {
104 ; CHECK-NEXT: [[DATA:%.*]] = load i64, i64* [[SRC:%.*]], align 8
105 ; CHECK-NEXT: br i1 [[C0:%.*]], label [[BB3:%.*]], label [[BB7:%.*]]
107 ; CHECK-NEXT: br i1 [[C1:%.*]], label [[BB4:%.*]], label [[BB5:%.*]]
109 ; CHECK-NEXT: tail call void @abort()
110 ; CHECK-NEXT: unreachable
112 ; CHECK-NEXT: [[PTR0:%.*]] = inttoptr i64 [[DATA]] to i32*
113 ; CHECK-NEXT: tail call void @sink0(i32* [[PTR0]])
114 ; CHECK-NEXT: br label [[BB9:%.*]]
116 ; CHECK-NEXT: tail call void @sink3(i64 [[DATA]])
117 ; CHECK-NEXT: br label [[BB9]]
119 ; CHECK-NEXT: ret void
122 %data = load i64, i64* %src, align 8
123 br i1 %c0, label %bb3, label %bb7
126 br i1 %c1, label %bb4, label %bb5
129 tail call void @abort()
133 %ptr0 = inttoptr i64 %data to i32*
134 tail call void @sink0(i32* %ptr0)
138 tail call void @sink3(i64 %data) ; non-cast use
145 declare void @abort()
147 declare void @sink0(i32*)
149 declare void @sink1(i32*)
151 declare void @sink2(<2 x i32>)
153 declare void @sink3(i64)