This does not solve PR17101, but it is one of the
underlying diffs noted here:
We could ease the one-use checks for the 'clear'
(no 'not' op) half of the transform, but I do not
know if that asymmetry would make things better
Name: masked bit set %sh1 = shl i32 1, %y %and = and i32 %sh1, %x %cmp = icmp ne i32 %and, 0 %r = zext i1 %cmp to i32 => %s = lshr i32 %x, %y %r = and i32 %s, 1 Name: masked bit clear %sh1 = shl i32 1, %y %and = and i32 %sh1, %x %cmp = icmp eq i32 %and, 0 %r = zext i1 %cmp to i32 => %xn = xor i32 %x, -1 %s = lshr i32 %xn, %y %r = and i32 %s, 1
Note: this is a re-post of a patch that I committed at:
I thought the change was small and obviously good, so I did not post it for pre-commit review per policy:
The commit was reverted though:
So either I am not seeing the problem with this patch, or it is uncovering a problem in another part of LLVM.