OSDN Git Service

[InstCombine] add more testcases for canonicalize (-X s/ Y) to -(X s/ Y).
authorChen Zheng <czhengsz@cn.ibm.com>
Tue, 9 Apr 2019 12:47:29 +0000 (12:47 +0000)
committerChen Zheng <czhengsz@cn.ibm.com>
Tue, 9 Apr 2019 12:47:29 +0000 (12:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358000 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/sdiv-canonicalize.ll

index 7f5ff06..8e1497b 100644 (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