[InstCombine] Canonicalize math-y conditional negation into a `select`
authorRoman Lebedev <lebedev.ri@gmail.com>
Mon, 2 Jan 2023 18:15:31 +0000 (21:15 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Mon, 2 Jan 2023 18:26:37 +0000 (21:26 +0300)
commitcf58063a4069b9ff11a99fd49345c1d188813feb
tree9b74992b117c6496185c0801233d094fd11ea6f6
parent1fb07108d4f8606464fad98a49e2cbae7ec4ae25
[InstCombine] Canonicalize math-y conditional negation into a `select`

https://alive2.llvm.org/ce/z/vPs-gZ

This is a larger pattern than would seem necessary, with minimal being:
* `and` https://alive2.llvm.org/ce/z/q9-MqK
* `or`  https://alive2.llvm.org/ce/z/AUUEMZ
* `xor` https://alive2.llvm.org/ce/z/dm3Ume
.. so for all others, we canonicalize away from math to `select`,
but there we canonicalize in the opposite direction.

Fixes https://github.com/llvm/llvm-project/issues/59791
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/test/Transforms/InstCombine/conditional-negation.ll