high-bit-signmask-with-trunc.ll
4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
define i32 @t0(i64 %x) {
; CHECK-LABEL: @t0(
; CHECK-NEXT: [[T0_NEG:%.*]] = ashr i64 [[X:%.*]], 63
; CHECK-NEXT: [[T1_NEG:%.*]] = trunc i64 [[T0_NEG]] to i32
; CHECK-NEXT: ret i32 [[T1_NEG]]
;
%t0 = lshr i64 %x, 63
%t1 = trunc i64 %t0 to i32
%r = sub i32 0, %t1
ret i32 %r
}
define i32 @t1_exact(i64 %x) {
; CHECK-LABEL: @t1_exact(
; CHECK-NEXT: [[T0_NEG:%.*]] = ashr exact i64 [[X:%.*]], 63
; CHECK-NEXT: [[T1_NEG:%.*]] = trunc i64 [[T0_NEG]] to i32
; CHECK-NEXT: ret i32 [[T1_NEG]]
;
%t0 = lshr exact i64 %x, 63
%t1 = trunc i64 %t0 to i32
%r = sub i32 0, %t1
ret i32 %r
}
define i32 @t2(i64 %x) {
; CHECK-LABEL: @t2(
; CHECK-NEXT: [[T0_NEG:%.*]] = lshr i64 [[X:%.*]], 63
; CHECK-NEXT: [[T1_NEG:%.*]] = trunc i64 [[T0_NEG]] to i32
; CHECK-NEXT: ret i32 [[T1_NEG]]
;
%t0 = ashr i64 %x, 63
%t1 = trunc i64 %t0 to i32
%r = sub i32 0, %t1
ret i32 %r
}
define i32 @t3_exact(i64 %x) {
; CHECK-LABEL: @t3_exact(
; CHECK-NEXT: [[T0_NEG:%.*]] = lshr exact i64 [[X:%.*]], 63
; CHECK-NEXT: [[T1_NEG:%.*]] = trunc i64 [[T0_NEG]] to i32
; CHECK-NEXT: ret i32 [[T1_NEG]]
;
%t0 = ashr exact i64 %x, 63
%t1 = trunc i64 %t0 to i32
%r = sub i32 0, %t1
ret i32 %r
}
define <2 x i32> @t4(<2 x i64> %x) {
; CHECK-LABEL: @t4(
; CHECK-NEXT: [[T0_NEG:%.*]] = ashr <2 x i64> [[X:%.*]], <i64 63, i64 63>
; CHECK-NEXT: [[T1_NEG:%.*]] = trunc <2 x i64> [[T0_NEG]] to <2 x i32>
; CHECK-NEXT: ret <2 x i32> [[T1_NEG]]
;
%t0 = lshr <2 x i64> %x, <i64 63, i64 63>
%t1 = trunc <2 x i64> %t0 to <2 x i32>
%r = sub <2 x i32> zeroinitializer, %t1
ret <2 x i32> %r
}
define <2 x i32> @t5(<2 x i64> %x) {
; CHECK-LABEL: @t5(
; CHECK-NEXT: [[T0:%.*]] = lshr <2 x i64> [[X:%.*]], <i64 63, i64 undef>
; CHECK-NEXT: [[T1:%.*]] = trunc <2 x i64> [[T0]] to <2 x i32>
; CHECK-NEXT: [[R:%.*]] = sub <2 x i32> <i32 0, i32 undef>, [[T1]]
; CHECK-NEXT: ret <2 x i32> [[R]]
;
%t0 = lshr <2 x i64> %x, <i64 63, i64 undef>
%t1 = trunc <2 x i64> %t0 to <2 x i32>
%r = sub <2 x i32> <i32 0, i32 undef>, %t1
ret <2 x i32> %r
}
declare void @use64(i64)
declare void @use32(i32)
define i32 @t6(i64 %x) {
; CHECK-LABEL: @t6(
; CHECK-NEXT: [[T0_NEG:%.*]] = ashr i64 [[X:%.*]], 63
; CHECK-NEXT: [[T0:%.*]] = lshr i64 [[X]], 63
; CHECK-NEXT: call void @use64(i64 [[T0]])
; CHECK-NEXT: [[T1_NEG:%.*]] = trunc i64 [[T0_NEG]] to i32
; CHECK-NEXT: ret i32 [[T1_NEG]]
;
%t0 = lshr i64 %x, 63
call void @use64(i64 %t0)
%t1 = trunc i64 %t0 to i32
%r = sub i32 0, %t1
ret i32 %r
}
define i32 @n7(i64 %x) {
; CHECK-LABEL: @n7(
; CHECK-NEXT: [[T0:%.*]] = lshr i64 [[X:%.*]], 63
; CHECK-NEXT: [[T1:%.*]] = trunc i64 [[T0]] to i32
; CHECK-NEXT: call void @use32(i32 [[T1]])
; CHECK-NEXT: [[R:%.*]] = sub nsw i32 0, [[T1]]
; CHECK-NEXT: ret i32 [[R]]
;
%t0 = lshr i64 %x, 63
%t1 = trunc i64 %t0 to i32
call void @use32(i32 %t1)
%r = sub i32 0, %t1
ret i32 %r
}
define i32 @n8(i64 %x) {
; CHECK-LABEL: @n8(
; CHECK-NEXT: [[T0:%.*]] = lshr i64 [[X:%.*]], 63
; CHECK-NEXT: call void @use64(i64 [[T0]])
; CHECK-NEXT: [[T1:%.*]] = trunc i64 [[T0]] to i32
; CHECK-NEXT: call void @use32(i32 [[T1]])
; CHECK-NEXT: [[R:%.*]] = sub nsw i32 0, [[T1]]
; CHECK-NEXT: ret i32 [[R]]
;
%t0 = lshr i64 %x, 63
call void @use64(i64 %t0)
%t1 = trunc i64 %t0 to i32
call void @use32(i32 %t1)
%r = sub i32 0, %t1
ret i32 %r
}
define i32 @n9(i64 %x) {
; CHECK-LABEL: @n9(
; CHECK-NEXT: [[T0:%.*]] = lshr i64 [[X:%.*]], 62
; CHECK-NEXT: [[T1:%.*]] = trunc i64 [[T0]] to i32
; CHECK-NEXT: [[R:%.*]] = sub nsw i32 0, [[T1]]
; CHECK-NEXT: ret i32 [[R]]
;
%t0 = lshr i64 %x, 62
%t1 = trunc i64 %t0 to i32
%r = sub i32 0, %t1
ret i32 %r
}
define i32 @n10(i64 %x) {
; CHECK-LABEL: @n10(
; CHECK-NEXT: [[T0_NEG:%.*]] = ashr i64 [[X:%.*]], 63
; CHECK-NEXT: [[T1_NEG:%.*]] = trunc i64 [[T0_NEG]] to i32
; CHECK-NEXT: [[R:%.*]] = add i32 [[T1_NEG]], 1
; CHECK-NEXT: ret i32 [[R]]
;
%t0 = lshr i64 %x, 63
%t1 = trunc i64 %t0 to i32
%r = sub i32 1, %t1
ret i32 %r
}