Efficient Knowledge Compilation Beyond Weighted Model Counting