[llvm] r358051 - [InstCombine] Directly call computeOverflow methods in OptimizeOverflowCheck; NFC
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 00:10:44 PDT 2019
Author: nikic
Date: Wed Apr 10 00:10:44 2019
New Revision: 358051
URL: http://llvm.org/viewvc/llvm-project?rev=358051&view=rev
Log:
[InstCombine] Directly call computeOverflow methods in OptimizeOverflowCheck; NFC
Instead of using the willOverflow helpers. This makes it easier to
extend handling of AlwaysOverflows.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=358051&r1=358050&r2=358051&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Wed Apr 10 00:10:44 2019
@@ -3967,8 +3967,9 @@ bool InstCombiner::OptimizeOverflowCheck
if (match(RHS, m_Zero()))
return SetResult(LHS, Builder.getFalse(), false);
+ OverflowResult OR;
if (OCF == OCF_UNSIGNED_ADD) {
- OverflowResult OR = computeOverflowForUnsignedAdd(LHS, RHS, &OrigI);
+ OR = computeOverflowForUnsignedAdd(LHS, RHS, &OrigI);
if (OR == OverflowResult::NeverOverflows)
return SetResult(Builder.CreateNUWAdd(LHS, RHS), Builder.getFalse(),
true);
@@ -3976,7 +3977,8 @@ bool InstCombiner::OptimizeOverflowCheck
if (OR == OverflowResult::AlwaysOverflows)
return SetResult(Builder.CreateAdd(LHS, RHS), Builder.getTrue(), true);
} else {
- if (willNotOverflowSignedAdd(LHS, RHS, OrigI))
+ OR = computeOverflowForSignedAdd(LHS, RHS, &OrigI);
+ if (OR == OverflowResult::NeverOverflows)
return SetResult(Builder.CreateNSWAdd(LHS, RHS), Builder.getFalse(),
true);
}
@@ -3989,12 +3991,15 @@ bool InstCombiner::OptimizeOverflowCheck
if (match(RHS, m_Zero()))
return SetResult(LHS, Builder.getFalse(), false);
+ OverflowResult OR;
if (OCF == OCF_UNSIGNED_SUB) {
- if (willNotOverflowUnsignedSub(LHS, RHS, OrigI))
+ OR = computeOverflowForUnsignedSub(LHS, RHS, &OrigI);
+ if (OR == OverflowResult::NeverOverflows)
return SetResult(Builder.CreateNUWSub(LHS, RHS), Builder.getFalse(),
true);
} else {
- if (willNotOverflowSignedSub(LHS, RHS, OrigI))
+ OR = computeOverflowForSignedSub(LHS, RHS, &OrigI);
+ if (OR == OverflowResult::NeverOverflows)
return SetResult(Builder.CreateNSWSub(LHS, RHS), Builder.getFalse(),
true);
}
@@ -4015,15 +4020,17 @@ bool InstCombiner::OptimizeOverflowCheck
if (match(RHS, m_One()))
return SetResult(LHS, Builder.getFalse(), false);
+ OverflowResult OR;
if (OCF == OCF_UNSIGNED_MUL) {
- OverflowResult OR = computeOverflowForUnsignedMul(LHS, RHS, &OrigI);
+ OR = computeOverflowForUnsignedMul(LHS, RHS, &OrigI);
if (OR == OverflowResult::NeverOverflows)
return SetResult(Builder.CreateNUWMul(LHS, RHS), Builder.getFalse(),
true);
if (OR == OverflowResult::AlwaysOverflows)
return SetResult(Builder.CreateMul(LHS, RHS), Builder.getTrue(), true);
} else {
- if (willNotOverflowSignedMul(LHS, RHS, OrigI))
+ OR = computeOverflowForSignedMul(LHS, RHS, &OrigI);
+ if (OR == OverflowResult::NeverOverflows)
return SetResult(Builder.CreateNSWMul(LHS, RHS), Builder.getFalse(),
true);
}
More information about the llvm-commits
mailing list