[llvm] 40fc602 - [InstCombine] Add extra test for non-overflowing usub.sat (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 31 07:55:35 PDT 2023


Author: Nikita Popov
Date: 2023-03-31T16:55:26+02:00
New Revision: 40fc60292b56b4c247bad9f862217c74a63799a7

URL: https://github.com/llvm/llvm-project/commit/40fc60292b56b4c247bad9f862217c74a63799a7
DIFF: https://github.com/llvm/llvm-project/commit/40fc60292b56b4c247bad9f862217c74a63799a7.diff

LOG: [InstCombine] Add extra test for non-overflowing usub.sat (NFC)

Same as the existing one, but with both nuw and nsw on the add.

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/saturating-add-sub.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/saturating-add-sub.ll b/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
index f1b763771ff5..dae370fbdb22 100644
--- a/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
+++ b/llvm/test/Transforms/InstCombine/saturating-add-sub.ll
@@ -965,6 +965,17 @@ define i8 @test_scalar_usub_add_nuw_no_ov(i8 %a) {
   ret i8 %r
 }
 
+define i8 @test_scalar_usub_add_nuw_nsw_no_ov(i8 %a) {
+; CHECK-LABEL: @test_scalar_usub_add_nuw_nsw_no_ov(
+; CHECK-NEXT:    [[B:%.*]] = add nuw nsw i8 [[A:%.*]], 10
+; CHECK-NEXT:    [[R:%.*]] = call i8 @llvm.usub.sat.i8(i8 [[B]], i8 9)
+; CHECK-NEXT:    ret i8 [[R]]
+;
+  %b = add nuw nsw i8 %a, 10
+  %r = call i8 @llvm.usub.sat.i8(i8 %b, i8 9)
+  ret i8 %r
+}
+
 define i8 @test_scalar_usub_add_nuw_eq(i8 %a) {
 ; CHECK-LABEL: @test_scalar_usub_add_nuw_eq(
 ; CHECK-NEXT:    ret i8 [[A:%.*]]


        


More information about the llvm-commits mailing list