The following condition expression ( a >> n) & 1 is converted to "bt a, n" instruction. It works on all intel targets.
But on AVX-512 it was broken because the expression is modified to (truncate (a >>n) to i1).
I added the new sequence (truncate (a >>n) to i1) to the BT pattern.
One more thing that required changes in TargetLowering.cpp is bad simplification of (truncate (a >>n) to i1) when we compare it to i1:
%tmp29 = lshr i32 %x, %n %tmp3 = and i32 1, %tmp29 %tmp4 = icmp ne i32 %tmp3, 1
is transferred to
%tmp29 = lshr i32 %x, %n %tmp3 = trunc i32 %tmp29 to i1 %tmp4 = icmp eq i32 %tmp3, 0
and then the 'bt' instruction should be selected:
%tmp4 = bt %x, %n