[PATCH] D104239: [SVE] Fix cast<FixedVectorType> in truncateToMinimalBitwidths
Dylan Fleming via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 25 08:30:08 PDT 2021
DylanFleming-arm updated this revision to Diff 354515.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104239/new/
https://reviews.llvm.org/D104239
Files:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/scalable-trunc-min-bitwidth.ll
Index: llvm/test/Transforms/LoopVectorize/scalable-trunc-min-bitwidth.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/LoopVectorize/scalable-trunc-min-bitwidth.ll
@@ -0,0 +1,31 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -loop-vectorize -scalable-vectorization=on -force-target-supports-scalable-vectors -S | FileCheck %s
+
+define void @trunc_minimal_bitwidth(i8* %bptr, i16* %hptr, i32 %sptr, i64 %dptr) {
+; CHECK-LABEL: @trunc_minimal_bitwidth(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
+; CHECK-NEXT: [[TMP0:%.*]] = load i8, i8* [[BPTR:%.*]], align 1
+; CHECK-NEXT: [[CONV:%.*]] = zext i8 [[TMP0]] to i32
+; CHECK-NEXT: [[CONV21:%.*]] = trunc i32 [[SPTR:%.*]] to i16
+; CHECK-NEXT: [[ARRAYIDX23:%.*]] = getelementptr inbounds i16, i16* [[HPTR:%.*]], i64 [[INDVARS_IV]]
+; CHECK-NEXT: store i16 [[CONV21]], i16* [[ARRAYIDX23]], align 2
+; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
+; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[DPTR:%.*]]
+; CHECK-NEXT: br label [[FOR_BODY]]
+entry:
+ br label %for.body
+
+for.body: ; preds = %for.body.pre, %for.body
+ %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+ %0 = load i8, i8* %bptr, align 1
+ %conv = zext i8 %0 to i32
+ %conv21 = trunc i32 %sptr to i16
+ %arrayidx23 = getelementptr inbounds i16, i16* %hptr, i64 %indvars.iv
+ store i16 %conv21, i16* %arrayidx23, align 2
+ %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+ %exitcond.not = icmp eq i64 %indvars.iv.next, %dptr
+ br label %for.body
+}
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3951,9 +3951,8 @@
Type *OriginalTy = I->getType();
Type *ScalarTruncatedTy =
IntegerType::get(OriginalTy->getContext(), KV.second);
- auto *TruncatedTy = FixedVectorType::get(
- ScalarTruncatedTy,
- cast<FixedVectorType>(OriginalTy)->getNumElements());
+ auto *TruncatedTy = VectorType::get(
+ ScalarTruncatedTy, cast<VectorType>(OriginalTy)->getElementCount());
if (TruncatedTy == OriginalTy)
continue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104239.354515.patch
Type: text/x-patch
Size: 2595 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210625/a14598cd/attachment.bin>
More information about the llvm-commits
mailing list