This is a work-in-progress.
Relevant discussions on Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=48353
In brief (cited from Roman Lebedev),
define i1 @src(i1 %cmp.i, i1 %cmp41) { %entry: %cmp4 = select i1 %cmp.i, i1 1, i1 %cmp41 ret i1 %cmp4 }
->
define i1 @tgt(i1 %cmp.i, i1 %cmp41) { %entry: %cmp4 = or i1 %cmp.i, %cmp41 ret i1 %cmp4 }
Transformation doesn't verify!
ERROR: Target is more poisonous than source
Example:
i1 %cmp.i = #x1 (1)
i1 %cmp41 = poison
Source:
i1 %cmp4 = #x1 (1)
Target:
i1 %cmp4 = poison
Source value: #x1 (1)
Target value: poison
Therefore, this patches disabled all such optimizations of select instructions that result in propagation of poison values.
In addition, minor changes are also made to ensure there is no functional problem after disabling the abovementioned optimizations.
Performance measurement should be taken to measure potential degradations. Currently in progress. Many regression tests should be updated as well.
This seems more complicated than necessary. Can't we just transfer the check from the block above to here:
We can do that as an NFC preliminary patch regardless of whether we decide to proceed with this or not.