Efficient in-hardware compression of on-chip data