[llvm] 87a294d - [LoopVectorize] Change getRuntimeVFAsFloat to use unsigned int->FP conversion

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 1 02:58:25 PDT 2021


Author: David Sherwood
Date: 2021-11-01T09:58:14Z
New Revision: 87a294d5eb5a0638d9b5887f0a620e7435f71415

URL: https://github.com/llvm/llvm-project/commit/87a294d5eb5a0638d9b5887f0a620e7435f71415
DIFF: https://github.com/llvm/llvm-project/commit/87a294d5eb5a0638d9b5887f0a620e7435f71415.diff

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

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

Differential revision: https://reviews.llvm.org/D112610

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 909788c5a87bd..84fbbf4309a3c 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1123,7 +1123,7 @@ static Value *getRuntimeVFAsFloat(IRBuilder<> &B, Type *FTy, ElementCount VF) {
   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,

diff  --git a/llvm/test/Transforms/LoopVectorize/scalable-inductions.ll b/llvm/test/Transforms/LoopVectorize/scalable-inductions.ll
index fd37d8659bef6..c8b23fba825bb 100644
--- a/llvm/test/Transforms/LoopVectorize/scalable-inductions.ll
+++ b/llvm/test/Transforms/LoopVectorize/scalable-inductions.ll
@@ -146,7 +146,7 @@ define void @add_unique_indf32(float* noalias nocapture %a, i64 %n) {
 ; 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


        


More information about the llvm-commits mailing list