Skip to content

[LoongArch] Improve pattern matching for AddLike predicate #82767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ class PatGprImm_32<SDPatternOperator OpNode, LAInst Inst, Operand ImmOpnd>
/// Predicates
def AddLike: PatFrags<(ops node:$A, node:$B),
[(add node:$A, node:$B), (or node:$A, node:$B)], [{
return N->getOpcode() == ISD::ADD || isOrEquivalentToAdd(N);
return CurDAG->isBaseWithConstantOffset(SDValue(N, 0));
}]>;

/// Simple arithmetic operations
Expand Down
3 changes: 1 addition & 2 deletions llvm/test/CodeGen/LoongArch/intrinsic-memcpy.ll
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ define void @box(ptr noalias nocapture noundef writeonly sret(%Box) align 16 der
; CHECK-NEXT: st.d $a1, $a0, 24
; CHECK-NEXT: ld.d $a1, $a3, 16
; CHECK-NEXT: st.d $a1, $a0, 16
; CHECK-NEXT: ori $a1, $a3, 8
; CHECK-NEXT: ld.d $a1, $a1, 0
; CHECK-NEXT: ld.d $a1, $a3, 8
; CHECK-NEXT: st.d $a1, $a0, 8
; CHECK-NEXT: addi.d $sp, $sp, 96
; CHECK-NEXT: ret
Expand Down