[llvm] [GlobalISel] Add srem-by-pow2 combine to intrem_combines (PR #194673)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 30 04:51:27 PDT 2026
================
@@ -6103,6 +6103,58 @@ void CombinerHelper::applyUDivByPow2(MachineInstr &MI) const {
MI.eraseFromParent();
}
+/// \p Reg is known to be +/- a power of 2.
+bool CombinerHelper::matchAbsPow2(Register Reg) const {
+ // Known bits only work for positive powers of 2.
+ if (isKnownToBeAPowerOfTwo(Reg, MRI, VT))
+ return true;
+
+ // Otherwise accept any constant whose absolute value is a power of 2.
----------------
arsenm wrote:
I don't understand why you need this special case handling of constants. Surely isKnownToBeAPowerOfTwo should handle constants?
https://github.com/llvm/llvm-project/pull/194673
More information about the llvm-commits
mailing list