[llvm] [InstCombine] Simplify `add nsw/nuw i1` to `or disjoint i1` (PR #118221)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 5 20:06:17 PST 2024
scottmcm wrote:
I noticed this looking at a bug where `||`ing two bits didn't optimize well, so tried this in godbolt thinking that I could use the `add_unchecked` intrinsic to do it, but then ended up fixing it in a way that didn't make *as* nice in IR, but worked well enough for the one specific case I was looking at.
Just figured that since this operation is normalized already, it should normalize to something better in this case, so that -- like normal with `or disjoint` -- it can be done with addition on platforms where that combines better than `xor` does.
(Specifically, I was looking at the carry flag from `uadd.with.overflow`, where seeing it `xor`ed together is weird, and probably not something that can turn into `ADC` on x86.)
https://github.com/llvm/llvm-project/pull/118221
More information about the llvm-commits
mailing list