This is an archive of the discontinued LLVM Phabricator instance.

[X86] Move some hasOneUse checks after checking what the opcode is.
ClosedPublic

Authored by craig.topper on Apr 15 2022, 3:55 PM.

Details

Summary

Calling hasOneUse can be expensive on nodes with multiple results.
Especially when some results are Chains. By checking the opcode first,
we can avoid walking the uses if it isn't an interesting node,
and thus avoid calling hasOneUse on a node that might have many uses.

Found by profiling the IR given in D123857.

Diff Detail

Event Timeline

craig.topper created this revision.Apr 15 2022, 3:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 15 2022, 3:55 PM
craig.topper requested review of this revision.Apr 15 2022, 3:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 15 2022, 3:55 PM

we can know avoid walking the uses if it isn't an interesting node

Should 'know' be 'now'?

craig.topper edited the summary of this revision. (Show Details)Apr 15 2022, 8:47 PM
RKSimon accepted this revision.Apr 16 2022, 6:49 AM

LGTM - with one minor

llvm/lib/Target/X86/X86ISelLowering.cpp
48905

I guess you can test the isNullConstant first ?

This revision is now accepted and ready to land.Apr 16 2022, 6:49 AM
This revision was landed with ongoing or failed builds.Apr 16 2022, 2:19 PM
This revision was automatically updated to reflect the committed changes.