]> granicus.if.org Git - llvm/commitdiff
[InstCombine] add testcases for sdiv exact flag fixing - NFC.
authorChen Zheng <czhengsz@cn.ibm.com>
Mon, 8 Apr 2019 05:49:15 +0000 (05:49 +0000)
committerChen Zheng <czhengsz@cn.ibm.com>
Mon, 8 Apr 2019 05:49:15 +0000 (05:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357884 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/div.ll

index 2bfa549d35a71050c2cd7699dcf9cfd2b87d8fd2..91747a555635fc97d6e2793777d3826489ab50fb 100644 (file)
@@ -760,3 +760,22 @@ define <2 x i8> @udiv_common_factor_not_nuw_vec(<2 x i8> %x, <2 x i8> %y, <2 x i
   ret <2 x i8> %c
 }
 
+define i32 @test_exact(i32 %x) {
+; CHECK-LABEL: @test_exact(
+; CHECK-NEXT:    [[DIV:%.*]] = sdiv i32 [[X:%.*]], -3
+; CHECK-NEXT:    ret i32 [[DIV]]
+;
+  %div = sdiv exact i32 %x, 3
+  %neg = sub nsw i32 0, %div
+  ret i32 %neg
+}
+
+define <2 x i64> @test_exact_vec(<2 x i64> %x) {
+; CHECK-LABEL: @test_exact_vec(
+; CHECK-NEXT:    [[DIV:%.*]] = sdiv <2 x i64> [[X:%.*]], <i64 -3, i64 -4>
+; CHECK-NEXT:    ret <2 x i64> [[DIV]]
+;
+  %div = sdiv exact <2 x i64> %x, <i64 3, i64 4>
+  %neg = sub nsw <2 x i64> zeroinitializer, %div
+  ret <2 x i64> %neg
+}