[llvm] 7177dc2 - [SDAG] Apply or-disjoint in SelectionDAG::isBaseWithConstantOffset (#88493)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 14 21:59:51 PDT 2024
Author: fengfeng
Date: 2024-04-15T13:59:48+09:00
New Revision: 7177dc2ef7f3a50a1d8b892d7bd298f3d52a1aab
URL: https://github.com/llvm/llvm-project/commit/7177dc2ef7f3a50a1d8b892d7bd298f3d52a1aab
DIFF: https://github.com/llvm/llvm-project/commit/7177dc2ef7f3a50a1d8b892d7bd298f3d52a1aab.diff
LOG: [SDAG] Apply or-disjoint in SelectionDAG::isBaseWithConstantOffset (#88493)
Signed-off-by: feng.feng <feng.feng at iluvatar.com>
Added:
llvm/test/CodeGen/AVR/base-with-add-like-constant-offset.ll
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 412e1de9fc41ca..fc972664e5f016 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5203,15 +5203,8 @@ bool SelectionDAG::isADDLike(SDValue Op) const {
}
bool SelectionDAG::isBaseWithConstantOffset(SDValue Op) const {
- if ((Op.getOpcode() != ISD::ADD && Op.getOpcode() != ISD::OR) ||
- !isa<ConstantSDNode>(Op.getOperand(1)))
- return false;
-
- if (Op.getOpcode() == ISD::OR &&
- !MaskedValueIsZero(Op.getOperand(0), Op.getConstantOperandAPInt(1)))
- return false;
-
- return true;
+ return Op.getNumOperands() == 2 && isa<ConstantSDNode>(Op.getOperand(1)) &&
+ (Op.getOpcode() == ISD::ADD || isADDLike(Op));
}
bool SelectionDAG::isKnownNeverNaN(SDValue Op, bool SNaN, unsigned Depth) const {
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..278dc4893a68d4
--- /dev/null
+++ b/llvm/test/CodeGen/AVR/base-with-add-like-constant-offset.ll
@@ -0,0 +1,18 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=avr %s -start-before=avr-isel -o - | FileCheck %s
+
+define void @test(i16 %x, ptr addrspace(1) %o) {
+; CHECK-LABEL: test:
+; CHECK: ; %bb.0:
+; CHECK-NEXT: mov r30, r22
+; CHECK-NEXT: mov r31, r23
+; CHECK-NEXT: std Z+11, r25
+; CHECK-NEXT: std Z+10, r24
+; CHECK-NEXT: ret
+ %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
+}
+
More information about the llvm-commits
mailing list