[llvm] Base with add like constant offset (PR #88493)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 12 03:04:29 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: fengfeng (fengfeng09)
<details>
<summary>Changes</summary>
Or-disjoint application.
---
Full diff: https://github.com/llvm/llvm-project/pull/88493.diff
2 Files Affected:
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (+3)
- (added) llvm/test/CodeGen/AVR/base-with-add-like-constant-offset.ll (+20)
``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 1dd0fa49a460f8..67feb47fef076f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5191,6 +5191,9 @@ bool SelectionDAG::isADDLike(SDValue Op) const {
}
bool SelectionDAG::isBaseWithConstantOffset(SDValue Op) const {
+ if (isADDLike(Op) && isa<ConstantSDNode>(Op.getOperand(1)))
+ return true;
+
if ((Op.getOpcode() != ISD::ADD && Op.getOpcode() != ISD::OR) ||
!isa<ConstantSDNode>(Op.getOperand(1)))
return false;
diff --git a/llvm/test/CodeGen/AVR/base-with-add-like-constant-offset.ll b/llvm/test/CodeGen/AVR/base-with-add-like-constant-offset.ll
new file mode 100644
index 00000000000000..6077f71b5efe06
--- /dev/null
+++ b/llvm/test/CodeGen/AVR/base-with-add-like-constant-offset.ll
@@ -0,0 +1,20 @@
+; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+; RUN: llc -mtriple=avr %s -start-before=avr-isel -o - -stop-after=avr-isel | FileCheck %s
+
+define void @test(i16 %x, ptr addrspace(1) %o) {
+ ; CHECK-LABEL: name: test
+ ; CHECK: bb.0 (%ir-block.0):
+ ; CHECK-NEXT: liveins: $r25r24, $r23r22
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:dregs = COPY $r23r22
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:dregs = COPY $r25r24
+ ; CHECK-NEXT: [[COPY2:%[0-9]+]]:ptrdispregs = COPY [[COPY]]
+ ; CHECK-NEXT: STDWPtrQRr [[COPY2]], 10, [[COPY1]] :: (store (s16) into %ir.addr, align 1, addrspace 1)
+ ; CHECK-NEXT: RET implicit $r1
+ %int = ptrtoint ptr addrspace(1) %o to i16
+ %or = or disjoint i16 %int, 10
+ %addr = inttoptr i16 %or to ptr addrspace(1)
+ store i16 %x, ptr addrspace(1) %addr
+ ret void
+}
+
``````````
</details>
https://github.com/llvm/llvm-project/pull/88493
More information about the llvm-commits
mailing list