[llvm] 7973346 - [RISCV] Use uint64_t countTrailingZeros/Ones instead of APInt. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 30 12:39:46 PDT 2022


Author: Craig Topper
Date: 2022-08-30T12:39:36-07:00
New Revision: 7973346d1672dda58c5ba33918ef38bf707daa42

URL: https://github.com/llvm/llvm-project/commit/7973346d1672dda58c5ba33918ef38bf707daa42
DIFF: https://github.com/llvm/llvm-project/commit/7973346d1672dda58c5ba33918ef38bf707daa42.diff

LOG: [RISCV] Use uint64_t countTrailingZeros/Ones instead of APInt. NFC

We know the type is 32 or 64 bits, we can use getZExtValue and
bypass the slow path check in APInt.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVInstrInfo.td

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
index ab6821045986..4a1acd5a47c1 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -431,13 +431,13 @@ def AddiPairImmLarge : SDNodeXForm<imm, [{
 }]>;
 
 def TrailingZeros : SDNodeXForm<imm, [{
-  return CurDAG->getTargetConstant(N->getAPIntValue().countTrailingZeros(),
+  return CurDAG->getTargetConstant(countTrailingZeros(N->getZExtValue()),
                                    SDLoc(N), N->getValueType(0));
 }]>;
 
 def XLenSubTrailingOnes : SDNodeXForm<imm, [{
   uint64_t XLen = Subtarget->getXLen();
-  uint64_t TrailingOnes = N->getAPIntValue().countTrailingOnes();
+  uint64_t TrailingOnes = countTrailingOnes(N->getZExtValue());
   return CurDAG->getTargetConstant(XLen - TrailingOnes, SDLoc(N),
                                    N->getValueType(0));
 }]>;


        


More information about the llvm-commits mailing list