[llvm] 76ba660 - [InstCombine] Follow-up to "When -A + B both have nsw flag, set nsw f… (#72282)

via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 08:42:06 PST 2023


Author: Z572
Date: 2023-11-15T00:42:02+08:00
New Revision: 76ba660688cb4b145d0d62d70a063a600b8aa667

URL: https://github.com/llvm/llvm-project/commit/76ba660688cb4b145d0d62d70a063a600b8aa667
DIFF: https://github.com/llvm/llvm-project/commit/76ba660688cb4b145d0d62d70a063a600b8aa667.diff

LOG: [InstCombine] Follow-up to "When -A + B both have nsw flag, set nsw f… (#72282)

…lag."

In 3c037b7306f57039e24a1470687cc39a795584ac, Use cast instead of dyn_cast for cast that cannot fail.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index d390d3a581fcaa2..2bd738c95ecaa7f 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -1488,7 +1488,7 @@ Instruction *InstCombinerImpl::visitAdd(BinaryOperator &I) {
 
     // -A + B --> B - A
     auto *Sub = BinaryOperator::CreateSub(RHS, A);
-    auto *OB0 = dyn_cast<OverflowingBinaryOperator>(LHS);
+    auto *OB0 = cast<OverflowingBinaryOperator>(LHS);
     Sub->setHasNoSignedWrap(I.hasNoSignedWrap() && OB0->hasNoSignedWrap());
 
     return Sub;


        


More information about the llvm-commits mailing list