1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

[SimplifyCFG] Add test for PR48778 (NFC)

The sdiv is incorrectly speculated.
This commit is contained in:
Nikita Popov 2021-01-17 19:57:59 +01:00
parent dd2009efe4
commit 1ded4d86ed

View File

@ -0,0 +1,26 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -simplifycfg -S < %s | FileCheck %s
; sdiv INT_MIN / -1 should not be speculated.
define i32 @test(i1 %cmp) {
; CHECK-LABEL: @test(
; CHECK-NEXT: else:
; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 -2147483648, -1
; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i32 [[DIV]], 0
; CHECK-NEXT: [[OR_COND:%.*]] = and i1 [[CMP:%.*]], [[CMP2]]
; CHECK-NEXT: [[MERGE:%.*]] = select i1 [[OR_COND]], i32 1, i32 0
; CHECK-NEXT: ret i32 [[MERGE]]
;
br i1 %cmp, label %if, label %else
if:
%div = sdiv i32 -2147483648, -1
%cmp2 = icmp ne i32 %div, 0
br i1 %cmp2, label %end, label %else
else:
ret i32 0
end:
ret i32 1
}