[llvm] 5fef5e6 - [GlobalISel] matchSDivByConst should use isNullValue() (#89666)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 22 15:47:22 PDT 2024
Author: AtariDreams
Date: 2024-04-22T15:47:18-07:00
New Revision: 5fef5e68dcb015a73220173d08ab0987b6cf1582
URL: https://github.com/llvm/llvm-project/commit/5fef5e68dcb015a73220173d08ab0987b6cf1582
DIFF: https://github.com/llvm/llvm-project/commit/5fef5e68dcb015a73220173d08ab0987b6cf1582.diff
LOG: [GlobalISel] matchSDivByConst should use isNullValue() (#89666)
It has been using isZeroValue(), which is for floats, not integers.
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index c5ee354f13b7b4..5545ec3b3ed0c6 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.
More information about the llvm-commits
mailing list