[InstCombine] add more testcases for canonicalize (-X s/ Y) to -(X s/ Y).

llvm-svn: 358000
This commit is contained in:
Chen Zheng 2019-04-09 12:47:29 +00:00
parent 55f79ef9fe
commit 11cf397292
1 changed files with 11 additions and 0 deletions

View File

@ -12,6 +12,17 @@ define i32 @test_sdiv_canonicalize_op0(i32 %x, i32 %y) {
ret i32 %sdiv
}
define i32 @test_sdiv_canonicalize_op0_exact(i32 %x, i32 %y) {
; CHECK-LABEL: @test_sdiv_canonicalize_op0_exact(
; CHECK-NEXT: [[NEG:%.*]] = sub nsw i32 0, [[X:%.*]]
; CHECK-NEXT: [[SDIV:%.*]] = sdiv exact i32 [[NEG]], [[Y:%.*]]
; CHECK-NEXT: ret i32 [[SDIV]]
;
%neg = sub nsw i32 0, %x
%sdiv = sdiv exact i32 %neg, %y
ret i32 %sdiv
}
define i32 @test_sdiv_canonicalize_op1(i32 %x, i32 %z) {
; CHECK-LABEL: @test_sdiv_canonicalize_op1(
; CHECK-NEXT: [[Y:%.*]] = mul i32 [[Z:%.*]], 3