Skip to content

Commit 8be39b3

Browse files
authored
[LoongArch] Improve pattern matching for AddLike predicate (#82767)
This commit updates the pattern matching logic for the `AddLike` predicate in `LoongArchInstrInfo.td` to use the `isBaseWithConstantOffset` function provided by `CurDAG`. This optimization aims to improve the efficiency of pattern matching by identifying cases where the operation can be represented as a base address plus a constant offset, which can lead to more efficient code generation.
1 parent 0f02431 commit 8be39b3

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

llvm/lib/Target/LoongArch/LoongArchInstrInfo.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ class PatGprImm_32<SDPatternOperator OpNode, LAInst Inst, Operand ImmOpnd>
10481048
/// Predicates
10491049
def AddLike: PatFrags<(ops node:$A, node:$B),
10501050
[(add node:$A, node:$B), (or node:$A, node:$B)], [{
1051-
return N->getOpcode() == ISD::ADD || isOrEquivalentToAdd(N);
1051+
return CurDAG->isBaseWithConstantOffset(SDValue(N, 0));
10521052
}]>;
10531053

10541054
/// Simple arithmetic operations

llvm/test/CodeGen/LoongArch/intrinsic-memcpy.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ define void @box(ptr noalias nocapture noundef writeonly sret(%Box) align 16 der
2222
; CHECK-NEXT: st.d $a1, $a0, 24
2323
; CHECK-NEXT: ld.d $a1, $a3, 16
2424
; CHECK-NEXT: st.d $a1, $a0, 16
25-
; CHECK-NEXT: ori $a1, $a3, 8
26-
; CHECK-NEXT: ld.d $a1, $a1, 0
25+
; CHECK-NEXT: ld.d $a1, $a3, 8
2726
; CHECK-NEXT: st.d $a1, $a0, 8
2827
; CHECK-NEXT: addi.d $sp, $sp, 96
2928
; CHECK-NEXT: ret

0 commit comments

Comments
 (0)