This is an archive of the discontinued LLVM Phabricator instance.

[SDAG] move x86 select-with-identity-constant fold behind a target hook; NFC
ClosedPublic

Authored by spatel on Feb 7 2022, 9:08 AM.

Details

Summary

This is no-functional-change-intended because only the x86 target enables the TLI hook currently.

We can add fmul/fdiv opcodes to the switch similar to the proposal D119111, but we don't need to make other changes like enabling target-specific combines.

We can also add integer opcodes (add, or, shl, etc.) to the switch because this function is called from all of the generic binary opcodes.

Diff Detail

Event Timeline

spatel created this revision.Feb 7 2022, 9:08 AM
spatel requested review of this revision.Feb 7 2022, 9:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2022, 9:08 AM
spatel edited the summary of this revision. (Show Details)Feb 7 2022, 9:17 AM
spatel updated this revision to Diff 406497.Feb 7 2022, 9:21 AM

Patch updated:
Restored TODO comments that were dropped in the previous revision.

A slight complication - its going to be tricky to extend this to handle non-binops in the future - fma (inc X86ISD variants) and some target shuffles come to mind

llvm/include/llvm/CodeGen/TargetLowering.h
2859

Add comment doxygen

spatel updated this revision to Diff 406544.Feb 7 2022, 11:28 AM

Added function comment for TLI hook.

LuoYuanke added inline comments.Feb 8 2022, 5:18 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
33421

Does this line exceed 80?

spatel marked an inline comment as done.Feb 8 2022, 5:24 AM
spatel added inline comments.
llvm/lib/Target/X86/X86ISelLowering.cpp
33421

Yes, I missed formatting this chunk. Will fix.

spatel updated this revision to Diff 406781.Feb 8 2022, 5:28 AM
spatel marked an inline comment as done.

Fixed 80-col violation.

LuoYuanke accepted this revision.Feb 8 2022, 5:30 AM

LGTM, thanks.

This revision is now accepted and ready to land.Feb 8 2022, 5:30 AM
pengfei added inline comments.Feb 8 2022, 5:46 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
2124

Nit: should this be moved out of the function and named shouldFoldSelectWithIdentityConstant?

spatel marked an inline comment as done.Feb 8 2022, 6:22 AM
spatel added inline comments.
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
2124

Yes - that is better. Will update. Thanks!

This revision was landed with ongoing or failed builds.Feb 8 2022, 6:55 AM
This revision was automatically updated to reflect the committed changes.
spatel marked an inline comment as done.