[clang] [flang] [llvm] Fix/172049 loop vectorize sigfpe (PR #172094)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 12 20:08:19 PST 2025
================
@@ -2907,6 +2907,10 @@ uint64_t LoopVectorizationCostModel::getPredBlockCostDivisor(
uint64_t BBFreq = getBFI().getBlockFreq(BB).getFrequency();
assert(HeaderFreq >= BBFreq &&
"Header has smaller block freq than dominated BB?");
+ // Guard against division by zero when BBFreq is 0.
+ // In such cases, return 1 to avoid undefined behavior.
+ if (BBFreq == 0)
----------------
lukel97 wrote:
FP division by zero isn't undefined behaviour, it should return -Inf. But in any case BlockFrequencyInfo should never return a zero frequency. If you add an assert here you'll see that BBFreq is never zero
https://github.com/llvm/llvm-project/pull/172094
More information about the llvm-commits
mailing list