[PATCH] D112610: [LoopVectorize] Change getRuntimeVFAsFloat to use unsigned int->FP conversion

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 27 03:45:27 PDT 2021


david-arm created this revision.
david-arm added reviewers: sdesmalen, kmclaughlin, bsmith, RosieSumpter.
Herald added a subscriber: hiraditya.
david-arm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

We never expect the runtime VF to be negative so we should use
the uitofp instruction instead of sitofp.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112610

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/scalable-inductions.ll


Index: llvm/test/Transforms/LoopVectorize/scalable-inductions.ll
===================================================================
--- llvm/test/Transforms/LoopVectorize/scalable-inductions.ll
+++ llvm/test/Transforms/LoopVectorize/scalable-inductions.ll
@@ -146,7 +146,7 @@
 ; CHECK-NEXT: %[[INDINIT:.*]] = fadd <vscale x 4 x float> %[[TMP2]], shufflevector (<vscale x 4 x float> insertelement (<vscale x 4 x float> poison, float 0.000000e+00, i32 0), <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer)
 ; CHECK-NEXT: %[[VSCALE:.*]] = call i32 @llvm.vscale.i32()
 ; CHECK-NEXT: %[[TMP3:.*]] = shl i32 %8, 2
-; CHECK-NEXT: %[[TMP4:.*]] = sitofp i32 %[[TMP3]] to float
+; CHECK-NEXT: %[[TMP4:.*]] = uitofp i32 %[[TMP3]] to float
 ; CHECK-NEXT: %[[INC:.*]] = fmul float %[[TMP4]], 2.000000e+00
 ; CHECK-NEXT: %[[TMP5:.*]] = insertelement <vscale x 4 x float> poison, float %[[INC]], i32 0
 ; CHECK-NEXT: %[[VECINC:.*]] = shufflevector <vscale x 4 x float> %[[TMP5]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1123,7 +1123,7 @@
   assert(FTy->isFloatingPointTy() && "Expected floating point type!");
   Type *IntTy = IntegerType::get(FTy->getContext(), FTy->getScalarSizeInBits());
   Value *RuntimeVF = getRuntimeVF(B, IntTy, VF);
-  return B.CreateSIToFP(RuntimeVF, FTy);
+  return B.CreateUIToFP(RuntimeVF, FTy);
 }
 
 void reportVectorizationFailure(const StringRef DebugMsg,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112610.382593.patch
Type: text/x-patch
Size: 1646 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211027/346b4587/attachment.bin>


More information about the llvm-commits mailing list