[llvm] d5248a4 - [SystemZ] Use llvm::bit_floor (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 22:10:14 PST 2023


Author: Kazu Hirata
Date: 2023-01-24T22:10:03-08:00
New Revision: d5248a46faed9071adffc65f82cac9bc0769b882

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

LOG: [SystemZ] Use llvm::bit_floor (NFC)

If x is known to be nonzero, findLastSet(x) returns the index of the
highest set bit counting from the LSB, so 1 << findLastSet(x) is the
same as llvm::bit_floor(x).

Added: 
    

Modified: 
    llvm/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp b/llvm/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp
index 20bab8991144..4eb58e27f7ad 100644
--- a/llvm/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp
@@ -108,7 +108,7 @@ SDValue SystemZSelectionDAGInfo::EmitTargetCodeForMemset(
       if (ByteVal == 0 || ByteVal == 255
               ? Bytes <= 16 && llvm::popcount(Bytes) <= 2
               : Bytes <= 4) {
-        unsigned Size1 = Bytes == 16 ? 8 : 1 << findLastSet(Bytes);
+        unsigned Size1 = Bytes == 16 ? 8 : llvm::bit_floor(Bytes);
         unsigned Size2 = Bytes - Size1;
         SDValue Chain1 = memsetStore(DAG, DL, Chain, Dst, ByteVal, Size1,
                                      Alignment, DstPtrInfo);


        


More information about the llvm-commits mailing list