[llvm] [AArch64] Use DAG->isAddLike in add_and_or_is_add (PR #79563)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 26 01:46:16 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-aarch64

Author: David Green (davemgreen)

<details>
<summary>Changes</summary>

This allows it to work with disjoint or's as well as computing the known bits.


---
Full diff: https://github.com/llvm/llvm-project/pull/79563.diff


2 Files Affected:

- (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/shift-accumulate.ll (+10) 


``````````diff
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index 03baa7497615e3d..678c69f968f6b64 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -899,7 +899,7 @@ def add_and_or_is_add : PatFrags<(ops node:$lhs, node:$rhs),
                          [(add node:$lhs, node:$rhs), (or node:$lhs, node:$rhs)],[{
    if (N->getOpcode() == ISD::ADD)
      return true;
-   return CurDAG->haveNoCommonBitsSet(N->getOperand(0), N->getOperand(1));
+   return CurDAG->isADDLike(SDValue(N,0));
 }]> {
   let GISelPredicateCode = [{
      // Only handle G_ADD for now. FIXME. build capability to compute whether
diff --git a/llvm/test/CodeGen/AArch64/shift-accumulate.ll b/llvm/test/CodeGen/AArch64/shift-accumulate.ll
index 2ca6c73d3b83192..1daa4ea397c8371 100644
--- a/llvm/test/CodeGen/AArch64/shift-accumulate.ll
+++ b/llvm/test/CodeGen/AArch64/shift-accumulate.ll
@@ -174,3 +174,13 @@ define <2 x i64> @usra_with_movi_v2i64(<16 x i8> %0, <16 x i8> %1) {
   %7 = or <2 x i64> %6, %5
   ret <2 x i64> %7
 }
+
+define <4 x i16> @usra_v4i16_disjointor(<4 x i16> %a) {
+; CHECK-LABEL: usra_v4i16_disjointor:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    usra v0.4h, v0.4h, #7
+; CHECK-NEXT:    ret
+  %s = lshr <4 x i16> %a, <i16 7, i16 7, i16 7, i16 7>
+  %o = or disjoint <4 x i16> %s, %a
+  ret <4 x i16> %o
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/79563


More information about the llvm-commits mailing list