Skip to content

Commit c89553a

Browse files
committed
[InstSimplify] Add test for or disjoint miscompile (NFC)
1 parent 8eb7053 commit c89553a

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

llvm/test/Transforms/InstSimplify/select.ll

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,18 @@ define i32 @test4(i32 %X) {
174174
ret i32 %cond
175175
}
176176

177+
; FIXME: This is a miscompile.
178+
define i32 @test4_disjoint(i32 %X) {
179+
; CHECK-LABEL: @test4_disjoint(
180+
; CHECK-NEXT: [[OR:%.*]] = or disjoint i32 [[X:%.*]], -2147483648
181+
; CHECK-NEXT: ret i32 [[OR]]
182+
;
183+
%cmp = icmp slt i32 %X, 0
184+
%or = or disjoint i32 %X, -2147483648
185+
%cond = select i1 %cmp, i32 %X, i32 %or
186+
ret i32 %cond
187+
}
188+
177189
; Same as above, but the compare isn't canonical
178190
define i32 @test4noncanon(i32 %X) {
179191
; CHECK-LABEL: @test4noncanon(
@@ -196,6 +208,16 @@ define i32 @test5(i32 %X) {
196208
ret i32 %cond
197209
}
198210

211+
define i32 @test5_disjoint(i32 %X) {
212+
; CHECK-LABEL: @test5_disjoint(
213+
; CHECK-NEXT: ret i32 [[X:%.*]]
214+
;
215+
%cmp = icmp slt i32 %X, 0
216+
%or = or disjoint i32 %X, -2147483648
217+
%cond = select i1 %cmp, i32 %or, i32 %X
218+
ret i32 %cond
219+
}
220+
199221
define i32 @test6(i32 %X) {
200222
; CHECK-LABEL: @test6(
201223
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
@@ -227,6 +249,16 @@ define i32 @test8(i32 %X) {
227249
ret i32 %cond
228250
}
229251

252+
define i32 @test8_disjoint(i32 %X) {
253+
; CHECK-LABEL: @test8_disjoint(
254+
; CHECK-NEXT: ret i32 [[X:%.*]]
255+
;
256+
%cmp = icmp sgt i32 %X, -1
257+
%or = or disjoint i32 %X, -2147483648
258+
%cond = select i1 %cmp, i32 %X, i32 %or
259+
ret i32 %cond
260+
}
261+
230262
define i32 @test9(i32 %X) {
231263
; CHECK-LABEL: @test9(
232264
; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
@@ -238,6 +270,18 @@ define i32 @test9(i32 %X) {
238270
ret i32 %cond
239271
}
240272

273+
; FIXME: This is a miscompile.
274+
define i32 @test9_disjoint(i32 %X) {
275+
; CHECK-LABEL: @test9_disjoint(
276+
; CHECK-NEXT: [[OR:%.*]] = or disjoint i32 [[X:%.*]], -2147483648
277+
; CHECK-NEXT: ret i32 [[OR]]
278+
;
279+
%cmp = icmp sgt i32 %X, -1
280+
%or = or disjoint i32 %X, -2147483648
281+
%cond = select i1 %cmp, i32 %or, i32 %X
282+
ret i32 %cond
283+
}
284+
241285
; Same as above, but the compare isn't canonical
242286
define i32 @test9noncanon(i32 %X) {
243287
; CHECK-LABEL: @test9noncanon(

0 commit comments

Comments
 (0)