[PATCH] D29729: [InstCombine] don't lose nsw/nuw from add by converting to xor

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 9 07:48:17 PST 2017


spatel added a comment.

In https://reviews.llvm.org/D29729#671331, @efriedma wrote:

> instcombine is allowed to use nsw to permit transformations which would otherwise be illegal.  instcombine should not avoid transformations for fear of dropping nsw or other metadata.


Thanks!

So for this patch, is instcombine behaving as expected already? Ie, it's ok to drop the nsw, some other pass has the responsibility to optimize this code:
https://godbolt.org/g/ezOlu6

Or should instcombine attempt to preserve the nsw despite changing the add into xor? The current mechanism would be to add an icmp+llvm.assume? Any better ideas?


https://reviews.llvm.org/D29729





More information about the llvm-commits mailing list