Hi, As discussed in PR90078, this patch checks possible infinite_cost overflow in ivopts. Also as discussed, overflow happens mostly because of cost scaling wrto bb_freq/loop_freq. For the moment, we only implement capping in comp_cost operators, while in next stage1, we may instead implement capping in get_scaled_computation_cost_at with more supporting benchmark data. BTW, I think switching costs around comparison between infinite_cost is unnecessary since there will be no overflow in integer after capping with infinite_cost. Bootstrap and test on x86_64, is it OK? Thanks, bin 2019-04-17 Bin Cheng PR tree-optimization/92078 * tree-ssa-loop-ivopts.c (comp_cost::operator +,-,+=,-+,/=,*=): Add checks for infinite_cost overflow. 2018-04-17 Bin Cheng PR tree-optimization/92078 * gcc/testsuite/g++.dg/tree-ssa/pr90078.C: New test.