@@ -506,28 +506,24 @@ Value *LoopIdiomVectorize::createPredicatedFindMismatch(
506
506
/* HasNSW=*/ true );
507
507
508
508
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 );
513
511
514
512
Value *VL = Builder.CreateIntrinsic (Intrinsic::experimental_get_vector_length,
515
513
{I64Type}, {AVL, VF, IsScalable});
516
514
Value *GepOffset = VectorIndexPhi;
517
515
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 ());
521
518
VectorType *TrueMaskTy =
522
519
VectorType::get (Builder.getInt1Ty (), VectorLoadType->getElementCount ());
523
520
Value *AllTrueMask = Constant::getAllOnesValue (TrueMaskTy);
524
521
Value *VectorLhsLoad = Builder.CreateIntrinsic (
525
522
Intrinsic::vp_load, {VectorLoadType, VectorLhsGep->getType ()},
526
523
{VectorLhsGep, AllTrueMask, VL}, nullptr , " lhs.load" );
527
524
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 ());
531
527
Value *VectorRhsLoad = Builder.CreateIntrinsic (
532
528
Intrinsic::vp_load, {VectorLoadType, VectorLhsGep->getType ()},
533
529
{VectorRhsGep, AllTrueMask, VL}, nullptr , " rhs.load" );
@@ -541,11 +537,9 @@ Value *LoopIdiomVectorize::createPredicatedFindMismatch(
541
537
" mismatch.cmp" );
542
538
Value *CTZ = Builder.CreateIntrinsic (
543
539
Intrinsic::vp_cttz_elts, {ResType, VectorMatchCmp->getType ()},
544
- {VectorMatchCmp, /* ZeroIsPoison=*/ Builder.getInt1 (true ), AllTrueMask,
540
+ {VectorMatchCmp, /* ZeroIsPoison=*/ Builder.getInt1 (false ), AllTrueMask,
545
541
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);
549
543
auto *VectorEarlyExit = BranchInst::Create (VectorLoopMismatchBlock,
550
544
VectorLoopIncBlock, MismatchFound);
551
545
Builder.Insert (VectorEarlyExit);
0 commit comments