From 11cf39729257f13586dbac0d991fdb53719be255 Mon Sep 17 00:00:00 2001 From: Chen Zheng Date: Tue, 9 Apr 2019 12:47:29 +0000 Subject: [PATCH] [InstCombine] add more testcases for canonicalize (-X s/ Y) to -(X s/ Y). llvm-svn: 358000 --- llvm/test/Transforms/InstCombine/sdiv-canonicalize.ll | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/sdiv-canonicalize.ll b/llvm/test/Transforms/InstCombine/sdiv-canonicalize.ll index 7f5ff06..8e1497b 100644 --- a/llvm/test/Transforms/InstCombine/sdiv-canonicalize.ll +++ b/llvm/test/Transforms/InstCombine/sdiv-canonicalize.ll @@ -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 -- 2.7.4