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

Chen Zheng via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 9 05:47:29 PDT 2019


Author: shchenz
Date: Tue Apr  9 05:47:29 2019
New Revision: 358000

URL: http://llvm.org/viewvc/llvm-project?rev=358000&view=rev
Log:
[InstCombine] add more testcases for canonicalize (-X s/ Y) to -(X s/ Y).

Modified:
    llvm/trunk/test/Transforms/InstCombine/sdiv-canonicalize.ll

Modified: llvm/trunk/test/Transforms/InstCombine/sdiv-canonicalize.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/sdiv-canonicalize.ll?rev=358000&r1=357999&r2=358000&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/sdiv-canonicalize.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/sdiv-canonicalize.ll Tue Apr  9 05:47:29 2019
@@ -12,6 +12,17 @@ define i32 @test_sdiv_canonicalize_op0(i
   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




More information about the llvm-commits mailing list