On 11/28/23 12:43 AM, HAO CHEN GUI wrote:
Hi,
   This patch passes down the equality only flags from
emit_block_cmp_hints to cmpmem optab so that the target specific expand
can generate optimized insns for equality only compare. Targets
(e.g. rs6000) can generate more efficient insn sequence if the block
compare is equality only.

   Bootstrapped and tested on x86 and powerpc64-linux BE and LE with
no regressions. Is this OK for trunk?

Thanks
Gui Haochen

ChangeLog
Expand: Pass down equality only flag to cmpmem expand

Targets (e.g. rs6000) can generate more efficient insn sequence if the
block compare is equality only.  This patch passes down the equality
only flags from emit_block_cmp_hints to cmpmem optab so that the target
specific expand can generate optimized insns for equality only compare.

gcc/
        * expr.cc (expand_cmpstrn_or_cmpmem): Rename to...
        (expand_cmpstrn): ...this.
        (expand_cmpmem): New function.  Pass down equality only flag to
        cmpmem expand.
        (emit_block_cmp_via_cmpmem): Add an argument for equality only
        flag and call expand_cmpmem instead of expand_cmpstrn_or_cmpmem.
        (emit_block_cmp_hints): Call emit_block_cmp_via_cmpmem with
        equality only flag.
        * expr.h (expand_cmpstrn, expand_cmpmem): Declare.
        * builtins.cc (expand_builtin_strcmp, expand_builtin_strncmp):
        Call expand_cmpstrn instead of expand_cmpstrn_or_cmpmem.
        * config/i386/i386.md (cmpmemsi): Add the sixth operand for
        equality only flag.
        * config/rs6000/rs6000.md (cmpmemsi): Likewise.
        * config/s390/s390.md (cmpmemsi): Likewise.
        * doc/md.texi (cmpmem): Modify the document and add an operand
        for equality only flag.
Is this patch still relevant? It was submitted after stage1 closed for gcc-14. With the trunk open for development, you should probably rebase and repost if the patch is still relevant/useful.

Conceptually knowing that we just want to do an equality comparison seems useful. I think there are other places where we track this information and utilize it to improve initial code generation.

jeff

Reply via email to