[llvm] [GlobalISel] matchSDivByConst should use isNullValue() (PR #89666)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 22 14:04:05 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-globalisel
Author: AtariDreams (AtariDreams)
<details>
<summary>Changes</summary>
It has been using isZeroValue(), which is for floats, not integers.
---
Full diff: https://github.com/llvm/llvm-project/pull/89666.diff
1 Files Affected:
- (modified) llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp (+3-7)
``````````diff
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.
``````````
</details>
https://github.com/llvm/llvm-project/pull/89666
More information about the llvm-commits
mailing list