Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[InstCombine] Do not request non-splat vector support in code reviews (NFC) #90709

Merged
merged 2 commits into from
May 4, 2024

Conversation

nikic
Copy link
Contributor

@nikic nikic commented May 1, 2024

The InstCombine contributor guide already says:

Handle non-splat vector constants if doing so is free, but do
not add handling for them if it adds any additional complexity
to the code.

I would like to strengthen this guideline to explicitly discourage asking contributors to implement non-splat support during code reviews.

I've found that the outcome is pretty much always bad whenever this request is made. Most recent example is in #90402, which initially had a reasonable implementation of a fold without non-splat support. In response to reviewer feedback, it was adjusted to use a more complex implementation that supports non-splat vectors. Now I have the choice between accepting unnecessary complexity into InstCombine, or asking a first-time contributor to undo their changes, which is really not something I want to do.

Non-trivial non-splat vector handling has done significant damage to the InstCombine code base in the past (mostly due to the work of a single contributor) and I am quite wary of repeating this mistake nowadays.

@RKSimon
Copy link
Collaborator

RKSimon commented May 1, 2024

Non-trivial non-splat vector handling has done significant damage to the InstCombine code base in the past (mostly due to the work of a single contributor) and I am quite wary of repeating this mistake nowadays.

I take it this is aimed at me, and I'm sorry if this has caused you problems.

Please can you give examples of the damaging combines?

@nikic
Copy link
Contributor Author

nikic commented May 1, 2024

Non-trivial non-splat vector handling has done significant damage to the InstCombine code base in the past (mostly due to the work of a single contributor) and I am quite wary of repeating this mistake nowadays.

I take it this is aimed at me, and I'm sorry if this has caused you problems.

Please can you give examples of the damaging combines?

Looks like not wanting to point fingers too much backfired -- I'm referring to Roman Lebedev here, who religiously implemented full non-splat vector support for every single new fold.

One specific example I remember is this one:

static Value *canonicalizeClampLike(SelectInst &Sel0, ICmpInst &Cmp0,

Modifying that kind of code is really annoying -- even if you want to do something "trivial" like supporting an additional predicate. An alternative implementation using ConstantRange utilities could handle all predicates uniformly with a lot less code -- but of course, you can't support non-splat vectors that way...

Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@RKSimon
Copy link
Collaborator

RKSimon commented May 1, 2024

Thanks for the clarification!


## Guidelines for reviewers

* Do not ask contributors to implement non-splat vector support in code
Copy link
Contributor

@goldsteinn goldsteinn May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this should be "new reviewers contributors". IIUC the motivation is that its complicated and may be too much for a novice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The problem is not just that it can be complicated, but that it is likely to significantly increase the number of required review iterations or even result in directly contradictory review feedback. We don't have a strong consensus on what exactly is acceptable when implementing non-splat vector support or what the best way of going about it is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully #85676 will change that :)

nikic added 2 commits May 3, 2024 12:05
… (NFC)

The InstCombine contributor guide already says:

> Handle non-splat vector constants if doing so is free, but do
> not add handling for them if it adds any additional complexity
> to the code.

I would like to strengthen this guideline to explicitly forbid
asking contributors to implement non-splat support during code
reviews.

I've found that the outcome is pretty much always bad whenever
this request is made. Most recent example is in llvm#90402, which
initially had a reasonable implementation of a fold without
non-splat support. In response to reviewer feedback, it was
adjusted to use a more complex implementation that supports
non-splat vectors. Now I have the choice between accepting this
unnecessary complexity into InstCombine, or asking a first-time
contributor to undo their changes, which is really not something
I want to do.

Complex non-splat vector handling has done significant damage to
the InstCombine code base in the past (mostly due to the work of
a single contributor) and I am quite wary of repeating this
mistake.
Copy link
Member

@dtcxzyw dtcxzyw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@nikic nikic merged commit f16e234 into llvm:main May 4, 2024
5 checks passed
@nikic nikic deleted the instcombine-non-splat branch May 4, 2024 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants