Skip to content

Commit 3babd98

Browse files
committed
Address review comments
1 parent c3700ca commit 3babd98

File tree

2 files changed

+36
-42
lines changed

2 files changed

+36
-42
lines changed

llvm/lib/Transforms/Vectorize/LoopIdiomVectorize.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -506,28 +506,24 @@ Value *LoopIdiomVectorize::createPredicatedFindMismatch(
506506
/*HasNSW=*/true);
507507

508508
auto *VectorLoadType = ScalableVectorType::get(LoadType, ByteCompareVF);
509-
auto *VF = ConstantInt::get(
510-
I32Type, VectorLoadType->getElementCount().getKnownMinValue());
511-
auto *IsScalable = ConstantInt::getBool(
512-
Builder.getContext(), VectorLoadType->getElementCount().isScalable());
509+
auto *VF = ConstantInt::get(I32Type, ByteCompareVF);
510+
auto *IsScalable = ConstantInt::getBool(Builder.getContext(), true);
513511

514512
Value *VL = Builder.CreateIntrinsic(Intrinsic::experimental_get_vector_length,
515513
{I64Type}, {AVL, VF, IsScalable});
516514
Value *GepOffset = VectorIndexPhi;
517515

518-
Value *VectorLhsGep = Builder.CreateGEP(LoadType, PtrA, GepOffset);
519-
if (GEPA->isInBounds())
520-
cast<GetElementPtrInst>(VectorLhsGep)->setIsInBounds(true);
516+
Value *VectorLhsGep =
517+
Builder.CreateGEP(LoadType, PtrA, GepOffset, "", GEPA->isInBounds());
521518
VectorType *TrueMaskTy =
522519
VectorType::get(Builder.getInt1Ty(), VectorLoadType->getElementCount());
523520
Value *AllTrueMask = Constant::getAllOnesValue(TrueMaskTy);
524521
Value *VectorLhsLoad = Builder.CreateIntrinsic(
525522
Intrinsic::vp_load, {VectorLoadType, VectorLhsGep->getType()},
526523
{VectorLhsGep, AllTrueMask, VL}, nullptr, "lhs.load");
527524

528-
Value *VectorRhsGep = Builder.CreateGEP(LoadType, PtrB, GepOffset);
529-
if (GEPB->isInBounds())
530-
cast<GetElementPtrInst>(VectorRhsGep)->setIsInBounds(true);
525+
Value *VectorRhsGep =
526+
Builder.CreateGEP(LoadType, PtrB, GepOffset, "", GEPB->isInBounds());
531527
Value *VectorRhsLoad = Builder.CreateIntrinsic(
532528
Intrinsic::vp_load, {VectorLoadType, VectorLhsGep->getType()},
533529
{VectorRhsGep, AllTrueMask, VL}, nullptr, "rhs.load");
@@ -541,11 +537,9 @@ Value *LoopIdiomVectorize::createPredicatedFindMismatch(
541537
"mismatch.cmp");
542538
Value *CTZ = Builder.CreateIntrinsic(
543539
Intrinsic::vp_cttz_elts, {ResType, VectorMatchCmp->getType()},
544-
{VectorMatchCmp, /*ZeroIsPoison=*/Builder.getInt1(true), AllTrueMask,
540+
{VectorMatchCmp, /*ZeroIsPoison=*/Builder.getInt1(false), AllTrueMask,
545541
VL});
546-
// RISC-V refines/lowers the poison returned by vp.cttz.elts to -1.
547-
Value *MismatchFound =
548-
Builder.CreateICmpSGE(CTZ, ConstantInt::get(ResType, 0));
542+
Value *MismatchFound = Builder.CreateICmpNE(CTZ, VL);
549543
auto *VectorEarlyExit = BranchInst::Create(VectorLoopMismatchBlock,
550544
VectorLoopIncBlock, MismatchFound);
551545
Builder.Insert(VectorEarlyExit);

0 commit comments

Comments
 (0)