Currently, clang ignores the 0 initialisation in finite math
For example:
double f_prod = 0;
double arr[1000];
for (size_t i = 0; i < 1000; i++) {
f_prod *= arr[i];
}Clang will ignore that f_prod is set to zero and it will generate assembly to iterate over the loop.
Can we use llvm::matchSimpleRecurrence()?
Here's an example usage within instcombine:
https://github.com/llvm/llvm-project/blob/1828c75d5f4ff657cf977476091fa224c8193e1d/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp#L2201