This is an archive of the discontinued LLVM Phabricator instance.

[X86][NFC]Use ref instead copy in for loop for SDValue::op_values()
AbandonedPublic

Authored by XinWang10 on Jun 1 2023, 11:08 PM.

Details

Reviewers
None
Summary

The for range loop in function LowerFMINIMUM_FMAXIMUM, it enumerate Op->op_values() with copy instead of ref, every element here is a SDValue which contains 1 pointer SDNode and an unsigned value, it's better to use ref here as what the author did in SelectionDAGNodes.h.

Diff Detail

Event Timeline

XinWang10 created this revision.Jun 1 2023, 11:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2023, 11:08 PM
XinWang10 requested review of this revision.Jun 1 2023, 11:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2023, 11:08 PM

Pretty sure the op is an SDValue not an SDUse.

This comment was removed by XinWang10.
XinWang10 added a comment.EditedJun 1 2023, 11:35 PM

Oh, I see. Thanks for pointing.

XinWang10 edited the summary of this revision. (Show Details)Jun 1 2023, 11:36 PM

We pass SDValue by value all over the SelectionD
AG code. And it looks pretty easy for a compiler to see the unsigned field is unused. Does this change really make a difference?

It should be const ref I think. But 16 byte by value is usually reasonably efficient

We pass SDValue by value all over the SelectionD
AG code. And it looks pretty easy for a compiler to see the unsigned field is unused. Does this change really make a difference?

I don't know about if compiler will do this opt to ignore the unused field for a class obj. Previously I mistook the enumerated element with SDUse which has more fields, but now the SDValue only has two fields, I also think this will make big difference. And if compiler would do the opt you said, maybe the program will go worse.

It should be const ref I think. But 16 byte by value is usually reasonably efficient

Thanks for pointing! I'm interested in where the info '16 byte' from, actually I searched for some while but didn't get useful info. I used to think that 8 byte could be reasonable because it can be fit in internal type.

We pass SDValue by value all over the SelectionD
AG code. And it looks pretty easy for a compiler to see the unsigned field is unused. Does this change really make a difference?

I don't know about if compiler will do this opt to ignore the unused field for a class obj.

I would expect SROA to break up the memcpy into scalar stores after that dead store elimination should be able to remove it.

For the pointer, I expect store to load forwarding should make it we don’t have to load from the stored copy. Then the store also becomes eligible for dead store elimination.

We pass SDValue by value all over the SelectionD
AG code. And it looks pretty easy for a compiler to see the unsigned field is unused. Does this change really make a difference?

I don't know about if compiler will do this opt to ignore the unused field for a class obj.

I would expect SROA to break up the memcpy into scalar stores after that dead store elimination should be able to remove it.

For the pointer, I expect store to load forwarding should make it we don’t have to load from the stored copy. Then the store also becomes eligible for dead store elimination.

Thanks for the explanation! I will give up this revision.

XinWang10 abandoned this revision.Jun 2 2023, 12:58 AM