[llvm] 9520fca - [InstCombine] add tests for sdiv-of-shl-1; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 10:21:15 PDT 2022


Author: Sanjay Patel
Date: 2022-10-07T13:16:55-04:00
New Revision: 9520fca46e09742c1249da2b156f340762c84690

URL: https://github.com/llvm/llvm-project/commit/9520fca46e09742c1249da2b156f340762c84690
DIFF: https://github.com/llvm/llvm-project/commit/9520fca46e09742c1249da2b156f340762c84690.diff

LOG: [InstCombine] add tests for sdiv-of-shl-1; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/sdiv-exact-by-power-of-two.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/sdiv-exact-by-power-of-two.ll b/llvm/test/Transforms/InstCombine/sdiv-exact-by-power-of-two.ll
index cb667fe0792d..8bc29d04118b 100644
--- a/llvm/test/Transforms/InstCombine/sdiv-exact-by-power-of-two.ll
+++ b/llvm/test/Transforms/InstCombine/sdiv-exact-by-power-of-two.ll
@@ -69,3 +69,25 @@ define <2 x i8> @n6_vec_negative(<2 x i8> %x) {
   %div = sdiv exact <2 x i8> %x, <i8 32, i8 128> ; non-non-negative divisor
   ret <2 x i8> %div
 }
+
+define i8 @shl1_nsw(i8 %x, i8 %y) {
+; CHECK-LABEL: @shl1_nsw(
+; CHECK-NEXT:    [[SHL:%.*]] = shl nuw nsw i8 1, [[Y:%.*]]
+; CHECK-NEXT:    [[DIV:%.*]] = sdiv exact i8 [[X:%.*]], [[SHL]]
+; CHECK-NEXT:    ret i8 [[DIV]]
+;
+  %shl = shl nsw i8 1, %y
+  %div = sdiv exact i8 %x, %shl
+  ret i8 %div
+}
+
+define i8 @shl1_nuw(i8 %x, i8 %y) {
+; CHECK-LABEL: @shl1_nuw(
+; CHECK-NEXT:    [[SHL:%.*]] = shl nuw i8 1, [[Y:%.*]]
+; CHECK-NEXT:    [[DIV:%.*]] = sdiv exact i8 [[X:%.*]], [[SHL]]
+; CHECK-NEXT:    ret i8 [[DIV]]
+;
+  %shl = shl nuw i8 1, %y
+  %div = sdiv exact i8 %x, %shl
+  ret i8 %div
+}


        


More information about the llvm-commits mailing list