[PATCH] D94149: [RISCV] Add a partial test of vector sadd.overflow to demonstrate intrinsics with multiple scalable vector results.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 5 19:34:59 PST 2021


craig.topper created this revision.
craig.topper added reviewers: frasercrmck, evandro, HsiangKai.
Herald added subscribers: NickHung, luismarques, apazos, sameer.abuasal, pzheng, s.egerton, lenary, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: LLVM.

This builds on D94142 <https://reviews.llvm.org/D94142> where scalable vectors are allowed in structs.

This test is incomplete because our isel patterns aren't ready
for the comparisons needed for overflow checking yet. See the FIXME.

I did have to fix one scalable vector issue in the vector type
creation for these intrinsics.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94149

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/test/CodeGen/RISCV/rvv/saddo-sdnode.ll


Index: llvm/test/CodeGen/RISCV/rvv/saddo-sdnode.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rvv/saddo-sdnode.ll
@@ -0,0 +1,22 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-v -verify-machineinstrs < %s | FileCheck %s
+
+; This test shows that we can at least partially handle the sadd.overflow
+; intrinsic which return multiple scalable vectors.
+
+; FIXME: This currently only uses the first result so DAG combine will turn
+; it into a regular add. We'll need more lowering or isel work to support the
+; overflow result.
+
+declare { <vscale x 2 x i32>, <vscale x 2 x i1> } @llvm.sadd.with.overflow.nxv2i32(<vscale x 2 x i32>, <vscale x 2 x i32>)
+
+define <vscale x 2 x i32> @foo(<vscale x 2 x i32> %x, <vscale x 2 x i32> %y) {
+; CHECK-LABEL: foo:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vsetvli a0, zero, e32,m1,ta,mu
+; CHECK-NEXT:    vadd.vv v16, v16, v17
+; CHECK-NEXT:    ret
+  %a = call { <vscale x 2 x i32>, <vscale x 2 x i1> } @llvm.sadd.with.overflow.nxv2i32(<vscale x 2 x i32> %x, <vscale x 2 x i32> %y)
+  %b = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i1> } %a, 0
+  ret <vscale x 2 x i32> %b
+}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -6577,7 +6577,7 @@
     EVT OverflowVT = MVT::i1;
     if (ResultVT.isVector())
       OverflowVT = EVT::getVectorVT(
-          *Context, OverflowVT, ResultVT.getVectorNumElements());
+          *Context, OverflowVT, ResultVT.getVectorElementCount());
 
     SDVTList VTs = DAG.getVTList(ResultVT, OverflowVT);
     setValue(&I, DAG.getNode(Op, sdl, VTs, Op1, Op2));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94149.314784.patch
Type: text/x-patch
Size: 1895 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210106/2a4559bf/attachment.bin>


More information about the llvm-commits mailing list