This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Add replaceOperand() helper
ClosedPublic

Authored by nikic on Jan 31 2020, 1:28 PM.

Details

Summary

Adds a replaceOperand() helper, which is like Instruction.setOperand() but adds the old operand to the worklist. This reduces the amount of missing or incorrect worklist management.

This only applies the helper to a relatively small subset of setOperand() calls in InstCombine, namely those of the pattern I.setOperand(); return &I;, where it is most obviously applicable.

Diff Detail

Event Timeline

nikic created this revision.Jan 31 2020, 1:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 31 2020, 1:28 PM
xbolva00 accepted this revision.Jan 31 2020, 2:10 PM

LG for me.

But please wait for other reviewers.

This revision is now accepted and ready to land.Jan 31 2020, 2:10 PM
spatel accepted this revision.Feb 3 2020, 7:02 AM

LGTM

llvm/lib/Transforms/InstCombine/InstCombineInternal.h
687

IMO, slightly easier to read if we name the "Operand" parameter "OpNum" or "OperandIndex" or some variant of those.

This revision was automatically updated to reflect the committed changes.
nikic marked an inline comment as done.