[PATCH][TargetInstrInfo] Fix the implementation of commuteInstruction to match the comment of the API

Quentin Colombet qcolombet at apple.com
Thu May 8 16:04:13 PDT 2014


The proposed patch relaxes the behavior of TargetInstrInfo::commuteInstruction when TargetInstrInfo::findCommutedOpIndices returns false.

Currently TargetInstrInfo triggers a fatal error in such situation whereas based on the comment in the API[1] it should just return nullptr. Indeed the only precondition that should be ensured is that the instruction must be commutable.

Spotted via code inspection.

Is it okay to commit?

  /// commuteInstruction - If a target has any instructions that are
  /// commutable but require converting to different instructions or making
  /// non-trivial changes to commute them, this method can overloaded to do
  /// that.  The default implementation simply swaps the commutable operands.
  /// If NewMI is false, MI is modified in place and returned; otherwise, a
  /// new machine instruction is created and returned.  Do not call this
  /// method for a non-commutable instruction, but there may be some cases
  /// where this method fails and returns null.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140508/4b3b7fc4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: commuteInstruction.patch
Type: application/octet-stream
Size: 656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140508/4b3b7fc4/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140508/4b3b7fc4/attachment-0001.html>

More information about the llvm-commits mailing list