[llvm] 1c4caec - [Mips] Use APInt::isMask/isShiftedMask to simplify code. (#116582)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 09:16:53 PST 2024
Author: Craig Topper
Date: 2024-11-18T09:16:50-08:00
New Revision: 1c4caece05f1885ba6ed80755d6b5de1b9f99579
URL: https://github.com/llvm/llvm-project/commit/1c4caece05f1885ba6ed80755d6b5de1b9f99579
DIFF: https://github.com/llvm/llvm-project/commit/1c4caece05f1885ba6ed80755d6b5de1b9f99579.diff
LOG: [Mips] Use APInt::isMask/isShiftedMask to simplify code. (#116582)
Added:
Modified:
llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp b/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
index afb027a533d5a6..c3e21e0ff7a0f0 100644
--- a/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
+++ b/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
@@ -614,11 +614,9 @@ bool MipsSEDAGToDAGISel::selectVSplatMaskL(SDValue N, SDValue &Imm) const {
if (selectVSplat(N.getNode(), ImmValue, EltTy.getSizeInBits()) &&
ImmValue.getBitWidth() == EltTy.getSizeInBits()) {
- // Extract the run of set bits starting with bit zero from the bitwise
- // inverse of ImmValue, and test that the inverse of this is the same
- // as the original value.
- if (ImmValue == ~(~ImmValue & ~(~ImmValue + 1))) {
-
+ // Check if we have a leading one, then check if the whole value is a
+ // shifted mask.
+ if (ImmValue.isNegative() && ImmValue.isShiftedMask()) {
Imm = CurDAG->getTargetConstant(ImmValue.popcount() - 1, SDLoc(N), EltTy);
return true;
}
@@ -647,9 +645,7 @@ bool MipsSEDAGToDAGISel::selectVSplatMaskR(SDValue N, SDValue &Imm) const {
if (selectVSplat(N.getNode(), ImmValue, EltTy.getSizeInBits()) &&
ImmValue.getBitWidth() == EltTy.getSizeInBits()) {
- // Extract the run of set bits starting with bit zero, and test that the
- // result is the same as the original value
- if (ImmValue == (ImmValue & ~(ImmValue + 1))) {
+ if (ImmValue.isMask()) {
Imm = CurDAG->getTargetConstant(ImmValue.popcount() - 1, SDLoc(N), EltTy);
return true;
}
More information about the llvm-commits
mailing list