Targets which provide a rotate make it possible to replace a sequence of
(XOR (SHL 1, x), -1) with (ROTL -2, x). This saves an instruction on
architectures like X86 and POWER(64).
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
David, the code and test case look great. The transformation is not trivial. Do you mind adding a line of comment that explains why -2 is used? Maybe an example input like 00000001 -> 11111101. Also a comment about how rotate can only pull in 1s and how large x values are undefined.
Comment Actions
Maybe a z3 proof in the commit message would make people feel a bit more at home with this also?
Comment Actions
I sent this out for review mainly for the SelectionDAG specific bits. I think the arithmetic behind it is pretty clear.