[PATCH] D28637: [PPC] Inline expansion of memcmp
Ulrich Weigand via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 16 10:24:39 PST 2017
uweigand added a comment.
In https://reviews.llvm.org/D28637#647220, @nemanjai wrote:
> In https://reviews.llvm.org/D28637#647200, @uweigand wrote:
> > On SystemZ, we use the existing callback EmitTargetCodeForMemcmp to expand memcmp calls. Can you explain how the new hook is different and why we'd need two hooks?
> I think the primary difference is that SystemZ has instructions that can perform these comparisons directly (i.e. with an instruction that compares memory from two addresses). On Power, we have to do the loads, comparison and branch out of the load sequence as soon as a mismatch is found. And the SDAG isn't well suited for adding new control flow.
> So I'd say the old hook is useful for targets that have instructions that can terminate the comparison on a mismatch without an explicit branch, whereas the new hook is useful for targets that don't.
Well, but on SystemZ we will also emit branches; memcmp will generally expand to a loop over CLC instructions. It's just that this is hidden behind a CLC_LOOP pseudo at the DAG level, which then gets expanded by a custom inserter.
More information about the llvm-commits