X86 does not to account for MinSize when lowering memset which leads to larger code size than it is possible to get, for example, with using rep stos which is already in use in GCC.
This patch must reduce code size for memset when MinSize is used.
Issue with some more details: https://github.com/llvm/llvm-project/issues/51196
Why do you need shouldEmitTargetCodeForMemset() if there already is EmitTargetCodeForMemset?