This patch is for frameindex calculations.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
Do you know why csky/hexagon need isOrEquivalentToAdd while other targets can produce efficient code without isOrEquivalentToAdd ?
Comment Actions
Other targets just do that manually in *ISelDAGToDAG.cpp file. E.g. X86:
case ISD::OR:
  // We want to look through a transform in InstCombine and DAGCombiner that
  // turns 'add' into 'or', so we can treat this 'or' exactly like an 'add'.
  // Example: (or (and x, 1), (shl y, 3)) --> (add (and x, 1), (shl y, 3))
  // An 'lea' can then be used to match the shift (multiply) and add:
  // and $1, %esi
  // lea (%rsi, %rdi, 8), %rax
  if (CurDAG->haveNoCommonBitsSet(N.getOperand(0), N.getOperand(1)) &&
      !matchAdd(N, AM, Depth))
    return false;
  break;ARM:
// Determine whether an ISD::OR's operands are suitable to turn the operation
// into an addition, which often has more compact encodings.
bool ARMDAGToDAGISel::SelectAddLikeOr(SDNode *Parent, SDValue N, SDValue &Out) {
  assert(Parent->getOpcode() == ISD::OR && "unexpected parent");
  Out = N;
  return CurDAG->haveNoCommonBitsSet(N, Parent->getOperand(1));
}| llvm/lib/Target/LoongArch/LoongArchInstrInfo.td | ||
|---|---|---|
| 591 | You can check for both ADD and OR in one PatFrags, e.g.: def add_like : PatFrags<(ops node:$lhs, node:$rhs),
                        [(add $lhs, $rhs), (or $lhs, $rhs)], [{
  return N->getOpcode() == ISD::ADD || isOrEquivalentToAdd(N);
}]>;This will halve the number of patterns. Up to you, of course. | |
Comment Actions
Agree, The DAGCombiner will almost certainly be generated ISD::OR operator for frameindex. (natural alignment attribute?)
| llvm/lib/Target/LoongArch/LoongArchInstrInfo.td | ||
|---|---|---|
| 591 | 
 Thanks, I will do that. | |
You can check for both ADD and OR in one PatFrags, e.g.:
def add_like : PatFrags<(ops node:$lhs, node:$rhs), [(add $lhs, $rhs), (or $lhs, $rhs)], [{ return N->getOpcode() == ISD::ADD || isOrEquivalentToAdd(N); }]>;This will halve the number of patterns. Up to you, of course.