[PATCH] D109163: [AArch64][sve] Prevent incorrect function call on fixed width vector

David Truby via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 2 09:05:14 PDT 2021


DavidTruby created this revision.
Herald added subscribers: psnobl, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: efriedma.
DavidTruby requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The isEssentiallyExtractHighSubvector function currently calls
getVectorNumElements on a type that in specific cases might be scalable.
Since this function only has correct behaviour at the moment on scalable
types anyway, the function can just return false when given a fixed type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109163

Files:
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/sve-no-typesize-warnings.ll


Index: llvm/test/CodeGen/AArch64/sve-no-typesize-warnings.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-no-typesize-warnings.ll
@@ -0,0 +1,34 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s | FileCheck %s
+
+target triple = "aarch64-unknown-linux-gnu"
+
+define i64 @sve_no_typesize_warning() #0 {
+; CHECK-LABEL: sve_no_typesize_warning:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    ld1r { v0.4h }, [x8]
+; CHECK-NEXT:    uabdl v1.4s, v0.4h, v0.4h
+; CHECK-NEXT:    uabal v1.4s, v0.4h, v0.4h
+; CHECK-NEXT:    ushll v0.2d, v1.2s, #0
+; CHECK-NEXT:    uaddw2 v0.2d, v0.2d, v1.4s
+; CHECK-NEXT:    addp d0, v0.2d
+; CHECK-NEXT:    fmov x0, d0
+; CHECK-NEXT:    ret
+entry:
+  %wide.masked.gather = call <4 x i16> @llvm.masked.gather.v4i16.v4p0i16(<4 x i16*> undef, i32 2, <4 x i1> <i1 true, i1 true, i1 true, i1 true>, <4 x i16> undef)
+  %wide.load25 = load <4 x i32>, <4 x i32>* undef, align 4
+  %i = zext <4 x i16> %wide.masked.gather to <4 x i32>
+  %i2 = sub nsw <4 x i32> %i, %i
+  %i3 = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %i2, i1 true)
+  %i5 = add nuw nsw <4 x i32> %i3, %i3
+  %i6 = zext <4 x i32> %i5 to <4 x i64>
+  %i7 = add <4 x i64> <i64 undef, i64 0, i64 0, i64 0>, %i6
+  %i8 = call i64 @llvm.vector.reduce.add.v4i64(<4 x i64> %i7)
+  ret i64 %i8
+}
+
+declare <4 x i16> @llvm.masked.gather.v4i16.v4p0i16(<4 x i16*>, i32 immarg, <4 x i1>, <4 x i16>)
+declare <4 x i32> @llvm.abs.v4i32(<4 x i32>, i1 immarg)
+declare i64 @llvm.vector.reduce.add.v4i64(<4 x i64>)
+
+attributes #0 = { "target-features"="+sve" }
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -13871,6 +13871,8 @@
     N = N.getOperand(0);
   if (N.getOpcode() != ISD::EXTRACT_SUBVECTOR)
     return false;
+  if (N.getOperand(0).getValueType().isScalableVector())
+    return false;
   return cast<ConstantSDNode>(N.getOperand(1))->getAPIntValue() ==
          N.getOperand(0).getValueType().getVectorNumElements() / 2;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109163.370287.patch
Type: text/x-patch
Size: 2225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210902/6d0e1810/attachment.bin>


More information about the llvm-commits mailing list