This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] Extend `combineFMulOrFDivWithIntPow2` to work for non-splat float vecs
ClosedPublic

Authored by goldstein.w.n on Jul 10 2023, 10:40 AM.

Details

Summary

Do so by extending matchUnaryPredicate to also work for
ConstantFPSDNode types then encapsulate the constant checks in a
lambda and pass it to matchUnaryPredicate.

Diff Detail

Event Timeline

goldstein.w.n created this revision.Jul 10 2023, 10:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2023, 10:40 AM
goldstein.w.n requested review of this revision.Jul 10 2023, 10:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2023, 10:41 AM
arsenm added inline comments.Jul 11 2023, 11:14 AM
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
3130–3131

I've never understood why ConstantSDNode isn't a common base to a ConstantInt and ConstantFPNode

I think you'd be better off just making this SDNode* and letting the implementation dyn_cast

Instead of variant, just add wrapper version that accepts sdnode

goldstein.w.n marked an inline comment as done.Jul 11 2023, 4:31 PM
RKSimon added inline comments.Jul 17 2023, 9:55 AM
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
3136

Why not just add a matchUnaryFpPredicate variant?

goldstein.w.n marked an inline comment as done.Jul 17 2023, 11:46 AM

Add matchUnaryFpPredicate API directly

RKSimon added inline comments.Jul 21 2023, 7:00 AM
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
3128

an -> a

3136

I meant just copy the existing matchUnaryPredicate implementation - the template wrapper + matchUnaryPredicateAnyNode look over complicated tbh (and a similar amount of code to maintain as just copying the original).

goldstein.w.n added inline comments.Jul 21 2023, 9:48 AM
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
3136

Really? Seems to me to be simpler to do node -> wrapper -> final. At this point adding any new constant type is just adding a new wrapper + adding isa type in anynode.

Imo cleaner like this but if you feel strongly Ill change.

RKSimon added inline comments.Jul 21 2023, 10:00 AM
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
3136

Yes please - as @arsenm mentioned, we'd be better off trying to add a ConstantSDBaseNode common class if we did need new constant node types.

goldstein.w.n marked 3 inline comments as done.Jul 21 2023, 11:30 AM

Just template matchunarypredicateimpl

RKSimon accepted this revision.Jul 22 2023, 5:11 AM

LGTM - cheers

This revision is now accepted and ready to land.Jul 22 2023, 5:11 AM