@@ -420,7 +420,6 @@ static Instruction *convertNvvmIntrinsicToLlvm(InstCombiner &IC,
420420// Returns nullopt if `II` is not one of the `isspacep` intrinsics.
421421static std::optional<Instruction *>
422422handleSpaceCheckIntrinsics (InstCombiner &IC, IntrinsicInst &II) {
423- Value *Op0 = II.getArgOperand (0 );
424423 // Returns true/false when we know the answer, nullopt otherwise.
425424 auto CheckASMatch = [](unsigned IID, unsigned AS) -> std::optional<bool > {
426425 if (AS == NVPTXAS::ADDRESS_SPACE_GENERIC ||
@@ -451,7 +450,7 @@ handleSpaceCheckIntrinsics(InstCombiner &IC, IntrinsicInst &II) {
451450 case Intrinsic::nvvm_isspacep_shared:
452451 case Intrinsic::nvvm_isspacep_shared_cluster:
453452 case Intrinsic::nvvm_isspacep_const: {
454- auto *Ty = II.getType ( );
453+ Value *Op0 = II.getArgOperand ( 0 );
455454 unsigned AS = Op0->getType ()->getPointerAddressSpace ();
456455 // Peek through ASC to generic AS.
457456 // TODO: we could dig deeper through both ASCs and GEPs.
@@ -460,7 +459,8 @@ handleSpaceCheckIntrinsics(InstCombiner &IC, IntrinsicInst &II) {
460459 AS = ASCO->getOperand (0 )->getType ()->getPointerAddressSpace ();
461460
462461 if (std::optional<bool > Answer = CheckASMatch (IID, AS))
463- return IC.replaceInstUsesWith (II, ConstantInt::get (Ty, *Answer));
462+ return IC.replaceInstUsesWith (II,
463+ ConstantInt::get (II.getType (), *Answer));
464464 return nullptr ; // Don't know the answer, got to check at run time.
465465 }
466466 default :
0 commit comments