[PATCH] D131672: [opt] Optimise for zero initialisation of product given finite math in Clang

Zain Jaffal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 11 05:34:50 PDT 2022


zjaffal created this revision.
zjaffal added a reviewer: fhahn.
zjaffal added a project: LLVM.
Herald added a subscriber: hiraditya.
Herald added a project: All.
zjaffal requested review of this revision.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131672

Files:
  llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
  llvm/test/Transforms/InstCombine/remove-loop-phi-fastmul.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131672.451814.patch
Type: text/x-patch
Size: 5913 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220811/8046f4df/attachment.bin>


More information about the llvm-commits mailing list