Skip to content

Commit 88d114e

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 9eb0bdf commit 88d114e

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

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

51935193
bool SelectionDAG::isBaseWithConstantOffset(SDValue Op) const {
5194-
if ((Op.getOpcode() != ISD::ADD && Op.getOpcode() != ISD::OR) ||
5195-
!isa<ConstantSDNode>(Op.getOperand(1)))
5196-
return false;
5197-
5198-
if (Op.getOpcode() == ISD::OR &&
5199-
!MaskedValueIsZero(Op.getOperand(0), Op.getConstantOperandAPInt(1)))
5200-
return false;
5201-
5202-
return true;
5194+
return isa<ConstantSDNode>(Op.getOperand(1)) &&
5195+
(Op.getOpcode() == ISD::ADD || isADDLike(Op));
52035196
}
52045197

52055198
bool SelectionDAG::isKnownNeverNaN(SDValue Op, bool SNaN, unsigned Depth) const {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
define void @test(i16 %x, ptr addrspace(1) %o) {
55
; CHECK-LABEL: test:
66
; CHECK: ; %bb.0:
7-
; CHECK-NEXT: ori r22, 10
87
; CHECK-NEXT: mov r30, r22
98
; CHECK-NEXT: mov r31, r23
10-
; CHECK-NEXT: std Z+1, r25
11-
; CHECK-NEXT: st Z, r24
9+
; CHECK-NEXT: std Z+11, r25
10+
; CHECK-NEXT: std Z+10, r24
1211
; CHECK-NEXT: ret
1312
%int = ptrtoint ptr addrspace(1) %o to i16
1413
%or = or disjoint i16 %int, 10

0 commit comments

Comments
 (0)