Skip to content

Commit b1fafcc

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 2985d1d commit b1fafcc

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
@@ -5203,15 +5203,8 @@ bool SelectionDAG::isADDLike(SDValue Op) const {
52035203
}
52045204

52055205
bool SelectionDAG::isBaseWithConstantOffset(SDValue Op) const {
5206-
if ((Op.getOpcode() != ISD::ADD && Op.getOpcode() != ISD::OR) ||
5207-
!isa<ConstantSDNode>(Op.getOperand(1)))
5208-
return false;
5209-
5210-
if (Op.getOpcode() == ISD::OR &&
5211-
!MaskedValueIsZero(Op.getOperand(0), Op.getConstantOperandAPInt(1)))
5212-
return false;
5213-
5214-
return true;
5206+
return isa<ConstantSDNode>(Op.getOperand(1)) &&
5207+
(Op.getOpcode() == ISD::ADD || isADDLike(Op));
52155208
}
52165209

52175210
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)