[InstCombine] restrict select of bit-tests to constant shift amounts
authorSanjay Patel <spatel@rotateright.com>
Fri, 1 Jul 2022 20:24:34 +0000 (16:24 -0400)
committerSanjay Patel <spatel@rotateright.com>
Fri, 1 Jul 2022 20:24:34 +0000 (16:24 -0400)
commit9c8a39c67b599b047510b181383a44547b2eead4
tree00e8a8d0d2f4972e7d0a5d144e913f1abf91f7e8
parentfeb4b628ac0901f9bd8925b580adc55244c2d694
[InstCombine] restrict select of bit-tests to constant shift amounts

This transform is responsible for a long-standing miscompile
as discussed in issue #47012 (was bugzilla #47668).

There was a proposal to correct it in D88432, but that was
abandoned and there hasn't been any recent activity to fix
it AFAICT.

The original patch D45108 started with a constant-shift-only
restriction and only expanded during review, so I don't think
there's much risk of perf regression on the motivating code.
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/select-of-bittest.ll