https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78103
--- Comment #21 from Segher Boessenkool <segher at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #19) > Created attachment 51211 [details] > gcc12-pr78103.patch > > Updated untested patch that uses define_insn_and_split in 2 cases instead of > the combine splitters so that it can work around the lack of LOG_LINKS. > The patch doesn't do anything with -mlzcnt, even when bsr or bsr + lea would > be shorter than mov + lzcnt + sub, but I'm afraid we can't do anything about > that, > we've lost information whether it is UB on zero or not with -mlzcnt and for > zero input all this is quite unsafe. That patch looks good to me. This is another argument for having some canonical form for stuff with extends, btw (you have a xor of a sign extension with a number that is zero in all bits that are sign copies (incl. the original sign) in the extension, so the extension could be pulled to the outside. But the way things are you really have to handle both xor(sext(x),c) and sext(xor(x,c)) in the machine description, both formulations are allowed, whether or not we teach simplify-rtx about this (if it doesn't already know :-) )