Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2023

Conversation

Z572
Copy link
Contributor

@Z572 Z572 commented Nov 14, 2023

…lag."

In 3c037b7, I've miss suggested about cast.

@llvmbot
Copy link
Member

llvmbot commented Nov 14, 2023

@llvm/pr-subscribers-llvm-transforms

Author: None (Z572)

Changes

…lag."

In 3c037b7, I've miss suggested about cast.


Full diff: https://github.com/llvm/llvm-project/pull/72282.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp (+1-1)
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;

Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second part of commit message should probably be something like "Use cast instead of dyn_cast for cast that cannot fail.`

@Z572 Z572 merged commit 76ba660 into llvm:main Nov 14, 2023
zahiraam pushed a commit to zahiraam/llvm-project that referenced this pull request Nov 20, 2023
llvm#72282)

…lag."

In 3c037b7, Use cast instead of dyn_cast for cast that cannot fail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants