@@ -463,7 +463,7 @@ class OpLowerer {
463
463
[[nodiscard]] bool lowerCtpopToCBits (Function &F) {
464
464
IRBuilder<> &IRB = OpBuilder.getIRB ();
465
465
Type *Int32Ty = IRB.getInt32Ty ();
466
-
466
+
467
467
return replaceFunction (F, [&](CallInst *CI) -> Error {
468
468
IRB.SetInsertPoint (CI);
469
469
SmallVector<Value *> Args;
@@ -473,48 +473,48 @@ class OpLowerer {
473
473
Type *FRT = F.getReturnType ();
474
474
if (FRT->isVectorTy ()) {
475
475
VectorType *VT = cast<VectorType>(FRT);
476
- RetTy = VectorType::get (RetTy, VT);
476
+ RetTy = VectorType::get (RetTy, VT);
477
477
}
478
-
479
- Expected<CallInst *> OpCall =
480
- OpBuilder. tryCreateOp ( dxil::OpCode::CBits, Args, CI->getName (), RetTy);
478
+
479
+ Expected<CallInst *> OpCall = OpBuilder. tryCreateOp (
480
+ dxil::OpCode::CBits, Args, CI->getName (), RetTy);
481
481
if (Error E = OpCall.takeError ())
482
- return E;
482
+ return E;
483
483
484
484
// If the result type is 32 bits we can do a direct replacement.
485
485
if (FRT->isIntOrIntVectorTy (32 )) {
486
486
CI->replaceAllUsesWith (*OpCall);
487
- CI->eraseFromParent ();
488
- return Error::success ();
487
+ CI->eraseFromParent ();
488
+ return Error::success ();
489
489
}
490
490
491
491
unsigned CastOp;
492
492
if (FRT->isIntOrIntVectorTy (16 ))
493
- CastOp = Instruction::ZExt;
493
+ CastOp = Instruction::ZExt;
494
494
else // must be 64 bits
495
- CastOp = Instruction::Trunc;
495
+ CastOp = Instruction::Trunc;
496
496
497
497
// It is correct to replace the ctpop with the dxil op and
498
498
// remove an existing cast iff the cast is the only usage of
499
499
// the ctpop
500
500
// can use hasOneUse instead of hasOneUser, because the user
501
501
// we care about should have one operand
502
502
if (CI->hasOneUse ()) {
503
- User *U = CI->user_back ();
504
- Instruction *I;
505
- if (isa<Instruction>(U) && (I = cast<Instruction>(U)) &&
506
- I->getOpcode () == CastOp && I->getType () == RetTy) {
503
+ User *U = CI->user_back ();
504
+ Instruction *I;
505
+ if (isa<Instruction>(U) && (I = cast<Instruction>(U)) &&
506
+ I->getOpcode () == CastOp && I->getType () == RetTy) {
507
507
I->replaceAllUsesWith (*OpCall);
508
- I->eraseFromParent ();
509
- CI->eraseFromParent ();
510
- return Error::success ();
511
- }
508
+ I->eraseFromParent ();
509
+ CI->eraseFromParent ();
510
+ return Error::success ();
511
+ }
512
512
}
513
513
514
514
// It is always correct to replace a ctpop with the dxil op and
515
515
// a cast
516
- Value *Cast = IRB. CreateZExtOrTrunc (*OpCall, F. getReturnType (),
517
- " ctpop.cast" );
516
+ Value *Cast =
517
+ IRB. CreateZExtOrTrunc (*OpCall, F. getReturnType (), " ctpop.cast" );
518
518
CI->replaceAllUsesWith (Cast);
519
519
CI->eraseFromParent ();
520
520
return Error::success ();
@@ -550,8 +550,8 @@ class OpLowerer {
550
550
HasErrors |= lowerTypedBufferStore (F);
551
551
break ;
552
552
case Intrinsic::ctpop:
553
- HasErrors |= lowerCtpopToCBits (F);
554
- break ;
553
+ HasErrors |= lowerCtpopToCBits (F);
554
+ break ;
555
555
}
556
556
Updated = true ;
557
557
}
0 commit comments