aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorAtariDreams <gfunni234@gmail.com>2024-04-22 18:47:18 -0400
committerGitHub <noreply@github.com>2024-04-22 15:47:18 -0700
commit5fef5e68dcb015a73220173d08ab0987b6cf1582 (patch)
tree9a41dd7c03cc48a6cb56d0a49f46476b1d36f1e3 /llvm/lib/CodeGen
parent579efe011b0c8909d88ac9fd068a30a5f32dd1b2 (diff)
downloadllvm-5fef5e68dcb015a73220173d08ab0987b6cf1582.tar.gz
llvm-5fef5e68dcb015a73220173d08ab0987b6cf1582.tar.bz2
llvm-5fef5e68dcb015a73220173d08ab0987b6cf1582.zip
[GlobalISel] matchSDivByConst should use isNullValue() (#89666)
It has been using isZeroValue(), which is for floats, not integers.
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index c5ee354f13b7..5545ec3b3ed0 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -5197,12 +5197,8 @@ bool CombinerHelper::matchUDivByConst(MachineInstr &MI) {
return false;
}
- auto CheckEltValue = [&](const Constant *C) {
- if (auto *CI = dyn_cast_or_null<ConstantInt>(C))
- return !CI->isZero();
- return false;
- };
- return matchUnaryPredicate(MRI, RHS, CheckEltValue);
+ return matchUnaryPredicate(
+ MRI, RHS, [](const Constant *C) { return C && !C->isNullValue(); });
}
void CombinerHelper::applyUDivByConst(MachineInstr &MI) {
@@ -5232,7 +5228,7 @@ bool CombinerHelper::matchSDivByConst(MachineInstr &MI) {
// If the sdiv has an 'exact' flag we can use a simpler lowering.
if (MI.getFlag(MachineInstr::MIFlag::IsExact)) {
return matchUnaryPredicate(
- MRI, RHS, [](const Constant *C) { return C && !C->isZeroValue(); });
+ MRI, RHS, [](const Constant *C) { return C && !C->isNullValue(); });
}
// Don't support the general case for now.