This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Expand `foldBinOpShiftWithShift` to handle multiple binops
Needs ReviewPublic

Authored by goldstein.w.n on Jun 13 2023, 6:27 PM.

Details

Reviewers
nikic
RKSimon
Summary

Previously we only did folds if had only had two total binops, but the
concept can be applied arbitrarily. The only thing that changes is
some shortcuts we made in the two total binop case with and are no
longer applicable.

This further helps with: D151807

Diff Detail

Event Timeline

goldstein.w.n created this revision.Jun 13 2023, 6:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 6:27 PM
goldstein.w.n requested review of this revision.Jun 13 2023, 6:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 6:27 PM

Is it possible to handle just the case binop(optional_binop1(shift), optional_binop2(shift))? I believe that's all that is necessary for the motivating cases and should allow a much cleaner implementation.

Is it possible to handle just the case binop(optional_binop1(shift), optional_binop2(shift))? I believe that's all that is necessary for the motivating cases and should allow a much cleaner implementation.

I started with just making all the binop checks optional and found myself using a vec anyways. As is, I don't think the current generic logic has any additional special cases that we wouldn't need to handle with 3-total binops. (i.e there is never special control flow b.c we may have more than 1 binop assosiated with a given shift, its basically all the same for handling 0/1). The NumInnerOps == 1 stuff would also be needed for 3-total case.