This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] fold more constant divisor to select-of-constants divisor
ClosedPublic

Authored by Chenbing.Zheng on Apr 1 2022, 11:45 PM.

Details

Summary

This patch slove TODO left in div.ll.

By adding a parameter to function FoldOpIntoSelect, we can fold more Ops to Select.
For this example, we tend to fold the division instruction, so we no longer care whether SelectInst is one use.

Diff Detail

Event Timeline

Chenbing.Zheng created this revision.Apr 1 2022, 11:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 11:45 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
Chenbing.Zheng requested review of this revision.Apr 1 2022, 11:45 PM
RKSimon added inline comments.Apr 7 2022, 2:01 AM
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
626

'Tend' sounds odd to me - maybe something like 'FoldWithMultiUse' to be more descriptive?

llvm/test/Transforms/InstCombine/div.ll
18

Are these changes from this patch or should you regenerate the file before hand to get rid of seperate changes like this?

address comments

Chenbing.Zheng marked 2 inline comments as done.Apr 7 2022, 2:26 AM
Chenbing.Zheng added inline comments.
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
626

'Tend' sounds odd to me - maybe something like 'FoldWithMultiUse' to be more descriptive?

Thanks for suggestion, it is mush batter

RKSimon accepted this revision.Apr 7 2022, 3:51 AM

LGTM - cheers

This revision is now accepted and ready to land.Apr 7 2022, 3:51 AM
This revision was landed with ongoing or failed builds.Apr 7 2022, 7:24 PM
This revision was automatically updated to reflect the committed changes.
Chenbing.Zheng marked an inline comment as done.