HomePhabricator

[ExpandMemCmp] Trigger on bcmp too.

Authored by courbet on Mar 20 2019, 4:51 AM.

Description

[ExpandMemCmp] Trigger on bcmp too.

Summary: Fixes 41150.

Reviewers: gchatelet

Subscribers: hiraditya, llvm-commits, ckennelly, sbenza, jyknight

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59593

llvm-svn: 356550

Details

Committed
courbetMar 20 2019, 4:51 AM
Differential Revision
D59593: [ExpandMemCmp] Trigger on bcmp too.
Parents
rG2acca37a2dcc: [X86] Use getConstantOperandAPInt to detect out-of-range shifts.
Branches
Unknown
Tags
Unknown

Event Timeline

offtopic a bit..

what about MergeICmps pass?
This pass turns chains of integer comparisons into memcmp. Does this new memcmp can be converted to bcmp, if possible?

courbet added a comment.EditedMar 20 2019, 6:46 AM

Yes, definitely. I was doing a pass of where LibFunc_memcmp was used, and that looks like another place.
(note that most comparison chains to only have a few comparisons, so they will be expanded in ExpandMemCmp())

Tracking this in PR40699

int cmpcomp(char *s, char *p) {

return memcmp(s,p,10) == bcmp(s,p,10) ;

}

GCC folds it to 1. Clang not.