mpl: avoid division by zero in soft blockage penalty calculation#10063
Conversation
Signed-off-by: João Mai <jmai@precisioninno.com>
There was a problem hiding this comment.
Code Review
This pull request updates SACoreSoftMacro.cpp to include a check for cluster area and refactors the retrieval of cluster objects within the calSoftBlockagePenalty function. A review comment recommends optimizing the nested loop structure by swapping the blockage and macro loops to reduce redundant calculations.
| for (const odb::Rect& blockage : soft_blockages_) { | ||
| for (const int macro_id : pos_seq_) { |
There was a problem hiding this comment.
The current nested loop structure iterates over blockages in the outer loop and macros in the inner loop. Since several properties of the macro (such as its bounding box and the macro_dominance calculation) are invariant with respect to the blockage, swapping the loops would allow hoisting these calculations out of the inner loop. This would improve efficiency by reducing redundant calls and calculations, which is particularly beneficial when the number of macros is large.
References
- When analyzing code within a loop, consider the entire loop structure to identify and eliminate redundant operations or calculations that can be hoisted or optimized.
|
clang-tidy review says "All clean, LGTM! 👍" |
Summary
Fix small defect detected by Coverity. The division by zero could happen if a macro was created with width or height equal to 0 or width and height equal to 1.
Type of Change
Verification
./etc/Build.sh).