@@ -941,9 +941,10 @@ static void scalarize(Instruction *I,
941941 llvm_unreachable (" Unsupported instruction type" );
942942
943943 Result = Builder.CreateInsertElement (Result, NewOp, Idx);
944- Instruction *ScalarizedI = cast<Instruction>(NewOp);
945- ScalarizedI->copyIRFlags (I, true );
946- Worklist.push_back (ScalarizedI);
944+ if (auto *ScalarizedI = dyn_cast<Instruction>(NewOp)) {
945+ ScalarizedI->copyIRFlags (I, true );
946+ Worklist.push_back (ScalarizedI);
947+ }
947948 }
948949
949950 I->replaceAllUsesWith (Result);
@@ -992,6 +993,7 @@ static void addToWorklist(Instruction &I,
992993static bool runImpl (Function &F, const TargetLowering &TLI,
993994 AssumptionCache *AC) {
994995 SmallVector<Instruction *, 4 > Worklist;
996+ bool Modified = false ;
995997
996998 unsigned MaxLegalFpConvertBitWidth =
997999 TLI.getMaxLargeFPConvertBitWidthSupported ();
@@ -1013,6 +1015,7 @@ static bool runImpl(Function &F, const TargetLowering &TLI,
10131015 if (!targetSupportsFrem (TLI, Ty) &&
10141016 FRemExpander::canExpandType (Ty->getScalarType ())) {
10151017 addToWorklist (I, Worklist);
1018+ Modified = true ;
10161019 }
10171020 break ;
10181021 case Instruction::FPToUI:
@@ -1022,6 +1025,7 @@ static bool runImpl(Function &F, const TargetLowering &TLI,
10221025 continue ;
10231026
10241027 addToWorklist (I, Worklist);
1028+ Modified = true ;
10251029 break ;
10261030 }
10271031 case Instruction::UIToFP:
@@ -1032,14 +1036,14 @@ static bool runImpl(Function &F, const TargetLowering &TLI,
10321036 continue ;
10331037
10341038 addToWorklist (I, Worklist);
1039+ Modified = true ;
10351040 break ;
10361041 }
10371042 default :
10381043 break ;
10391044 }
10401045 }
10411046
1042- bool Modified = !Worklist.empty ();
10431047 while (!Worklist.empty ()) {
10441048 Instruction *I = Worklist.pop_back_val ();
10451049 if (I->getOpcode () == Instruction::FRem) {
0 commit comments