Skip to content

Commit fa99586

Browse files
committed
[SelectionDAG] Disjoint Or could be also constant offset.
If the addr base of a Load/Store Inst is an Or-disjoint with a constant, it could be selected to an MI with constans offset if the target have. Signed-off-by: feng.feng <[email protected]>
1 parent 306ae56 commit fa99586

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5191,6 +5191,9 @@ bool SelectionDAG::isADDLike(SDValue Op) const {
51915191
}
51925192

51935193
bool SelectionDAG::isBaseWithConstantOffset(SDValue Op) const {
5194+
if (isADDLike(Op) && isa<ConstantSDNode>(Op.getOperand(1)))
5195+
return true;
5196+
51945197
if ((Op.getOpcode() != ISD::ADD && Op.getOpcode() != ISD::OR) ||
51955198
!isa<ConstantSDNode>(Op.getOperand(1)))
51965199
return false;

llvm/test/CodeGen/AVR/base-with-add-like-constant-offset.ll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ define void @test(i16 %x, ptr addrspace(1) %o) {
66
; CHECK: bb.0 (%ir-block.0):
77
; CHECK-NEXT: liveins: $r25r24, $r23r22
88
; CHECK-NEXT: {{ $}}
9-
; CHECK-NEXT: [[COPY:%[0-9]+]]:dldregs = COPY $r23r22
9+
; CHECK-NEXT: [[COPY:%[0-9]+]]:dregs = COPY $r23r22
1010
; CHECK-NEXT: [[COPY1:%[0-9]+]]:dregs = COPY $r25r24
11-
; CHECK-NEXT: [[ORIWRdK:%[0-9]+]]:dldregs = ORIWRdK [[COPY]], 10, implicit-def dead $sreg
12-
; CHECK-NEXT: [[COPY2:%[0-9]+]]:ptrdispregs = COPY [[ORIWRdK]]
13-
; CHECK-NEXT: STWPtrRr killed [[COPY2]], [[COPY1]] :: (store (s16) into %ir.addr, align 1, addrspace 1)
11+
; CHECK-NEXT: [[COPY2:%[0-9]+]]:ptrdispregs = COPY [[COPY]]
12+
; CHECK-NEXT: STDWPtrQRr [[COPY2]], 10, [[COPY1]] :: (store (s16) into %ir.addr, align 1, addrspace 1)
1413
; CHECK-NEXT: RET implicit $r1
1514
%int = ptrtoint ptr addrspace(1) %o to i16
1615
%or = or disjoint i16 %int, 10

0 commit comments

Comments
 (0)