[SystemZ] Use llvm::bit_floor (NFC)
authorKazu Hirata <kazu@google.com>
Wed, 25 Jan 2023 06:10:02 +0000 (22:10 -0800)
committerKazu Hirata <kazu@google.com>
Wed, 25 Jan 2023 06:10:03 +0000 (22:10 -0800)
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).

llvm/lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp

index 20bab89..4eb58e2 100644 (file)
@@ -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);