[PATCH] D23067: TargetInstrInfo: add two new target hooks to analyse branch offsets

Sjoerd Meijer via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 09:12:42 PDT 2016


SjoerdMeijer added inline comments.

================
Comment at: include/llvm/Target/TargetInstrInfo.h:486-488
@@ +485,5 @@
+
+  /// Return the opcode if there exist a branch instruction with a smaller
+  /// encoding, or -1 otherwise.
+  virtual int optimizeShortBranch(MachineInstr &MI, int64_t Offset) const {
+    return -1;
----------------
arsenm wrote:
> I think the design of this one is too restrictive, since it implies the branch can be optimized by simply changing the instruction opcode. I would expect such a simple change be handled by MC. If you still need the MI transformation, it would be better to expect the target to modify the branch (or insert a new instruction sequence to replace it) so that the target is free to change the operand structure or whatever else it needs to do
Changing it so that the target can modify the branch seems indeed to be more in line with other hooks. I will make this change. I am not entirely sure that I am following the part about simple transformations being done in MC. 


https://reviews.llvm.org/D23067





More information about the llvm-commits mailing list