File tree 1 file changed +10
-6
lines changed
llvm/lib/Transforms/Utils
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -398,11 +398,13 @@ bool llvm::expandRemainder(BinaryOperator *Rem) {
398
398
Rem->dropAllReferences ();
399
399
Rem->eraseFromParent ();
400
400
401
- // If we didn't actually generate a udiv instruction, we're done
402
- BinaryOperator *BO = dyn_cast<BinaryOperator>(Builder.GetInsertPoint ());
403
- if (!BO || BO->getOpcode () != Instruction::URem)
401
+ // If we didn't actually generate an urem instruction, we're done
402
+ // This happens for example if the input were constant. In this case the
403
+ // Builder insertion point was unchanged
404
+ if (Rem == Builder.GetInsertPoint ())
404
405
return true ;
405
406
407
+ BinaryOperator *BO = dyn_cast<BinaryOperator>(Builder.GetInsertPoint ());
406
408
Rem = BO;
407
409
}
408
410
@@ -456,11 +458,13 @@ bool llvm::expandDivision(BinaryOperator *Div) {
456
458
Div->dropAllReferences ();
457
459
Div->eraseFromParent ();
458
460
459
- // If we didn't actually generate a udiv instruction, we're done
460
- BinaryOperator *BO = dyn_cast<BinaryOperator>(Builder.GetInsertPoint ());
461
- if (!BO || BO->getOpcode () != Instruction::UDiv)
461
+ // If we didn't actually generate an udiv instruction, we're done
462
+ // This happens for example if the input were constant. In this case the
463
+ // Builder insertion point was unchanged
464
+ if (Div == Builder.GetInsertPoint ())
462
465
return true ;
463
466
467
+ BinaryOperator *BO = dyn_cast<BinaryOperator>(Builder.GetInsertPoint ());
464
468
Div = BO;
465
469
}
466
470
You can’t perform that action at this time.
0 commit comments