adding optimization to dense difference logic

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>