https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110588
Roger Sayle <roger at nextmovesoftware dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |roger at nextmovesoftware dot com Status|UNCONFIRMED |ASSIGNED Ever confirmed|0 |1 Assignee|unassigned at gcc dot gnu.org |roger at nextmovesoftware dot com Last reconfirmed| |2023-07-08 --- Comment #1 from Roger Sayle <roger at nextmovesoftware dot com> --- Thanks Andrew. I have a patch (a define_split in i386.md) that's currently bootstrapping and regression testing. But perhaps this should also be fixed at the tree-level by match.pd canonicalizing ((T)(x & C)) ^ C to (T)((~x) & C) when T is not wider than X and X is not wider than WORD_MODE. It's tricky to compare the costs of integer operations in different precisions, but WORD_MODE (and int) operations are (typically) always cheap (and I believe unary operations are preferred over binary operations (with immediate constants)).