This is an archive of the discontinued LLVM Phabricator instance.

[MemCpyOpt] Use usub_sat in processMemSetMemCpyDependence
AbandonedPublic

Authored by bjope on Oct 10 2022, 7:12 AM.

Details

Reviewers
None
Summary

Select usub_sat directly for the memset length calculation, instead
of using a cmp/sub/select pattern than InstCombine later would turn
into usub_sat.

Diff Detail

Event Timeline

bjope created this revision.Oct 10 2022, 7:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 10 2022, 7:12 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
bjope requested review of this revision.Oct 10 2022, 7:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 10 2022, 7:12 AM
bjope added inline comments.Oct 10 2022, 2:04 PM
llvm/include/llvm/IR/IRBuilder.h
945

Looks like we do not handle this in the ConstantFolder so if LHS and RHS are constant the usub_sat will remain in the IR until we simplify this.

llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
1279

Maybe this isn't always desired. One situation I could imagine is that if for example the code is comparing DestSize and SrcSize for other reasons, then maybe the InstCombine transform is more careful and thinking that it isn't preferable to use usub_sat as we need to do the comparison anyhow.

bjope abandoned this revision.Sep 9 2023, 6:30 AM

No plan on landing this right now. So I'll abandon this idea.