@@ -357,7 +357,6 @@ static bool expandFRem(BinaryOperator &I, std::optional<SimplifyQuery> &SQ) {
357357 LLVM_DEBUG (dbgs () << " Expanding instruction: " << I << ' \n ' );
358358
359359 Type *Ty = I.getType ();
360- assert (Ty->isFloatingPointTy () && " Instruction should have been scalarized" );
361360 assert (FRemExpander::canExpandType (Ty));
362361
363362 FastMathFlags FMF = I.getFastMathFlags ();
@@ -927,16 +926,17 @@ static void scalarize(Instruction *I, SmallVectorImpl<Instruction *> &Replace) {
927926 Value *Result = PoisonValue::get (VTy);
928927 for (unsigned Idx = 0 ; Idx < NumElements; ++Idx) {
929928 Value *Ext = Builder.CreateExtractElement (I->getOperand (0 ), Idx);
930- Value *Op;
931- if (isa<BinaryOperator>(I))
932- Op = Builder.CreateBinOp (
933- cast<BinaryOperator>(I)->getOpcode (), Ext,
929+ auto *BinOp = dyn_cast<BinaryOperator>(I);
930+ Value *NewOp;
931+ if (BinOp)
932+ NewOp = Builder.CreateBinOp (
933+ BinOp->getOpcode (), Ext,
934934 Builder.CreateExtractElement (I->getOperand (1 ), Idx));
935935 else
936- Op = Builder.CreateCast (cast<CastInst>(I)->getOpcode (), Ext,
937- I->getType ()->getScalarType ());
938- Result = Builder.CreateInsertElement (Result, Op , Idx);
939- if (auto *ScalarizedI = dyn_cast<Instruction>(Op )) {
936+ NewOp = Builder.CreateCast (cast<CastInst>(I)->getOpcode (), Ext,
937+ I->getType ()->getScalarType ());
938+ Result = Builder.CreateInsertElement (Result, NewOp , Idx);
939+ if (auto *ScalarizedI = dyn_cast<Instruction>(NewOp )) {
940940 ScalarizedI->copyIRFlags (I, true );
941941 Replace.push_back (ScalarizedI);
942942 }
0 commit comments