Here is a third patch which improves the code a different way, one which seems better as combine.c already had the code which is supposed to do the combining of:
(set (x) (const))
(set (zero_extract (x a b) (const))
But it forgot that x can be a non subreg if we are using a zero extract.
Also it is easy add the case where the second set does not have a const there and optimize it to a shift followed by an and which gets my testcase too.
Created attachment 28428
A third patch
Here is a third patch which improves the code a different way, one which seems better as combine.c already had the code which is supposed to do the combining of:
(set (x) (const))
(set (zero_extract (x a b) (const))
But it forgot that x can be a non subreg if we are using a zero extract.
Also it is easy add the case where the second set does not have a const there and optimize it to a shift followed by an and which gets my testcase too.