[PATCH] D131757: [instcombine] Check for zero initialisation optimisation of a product given fast flags are enabled in clang.

Zain Jaffal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 12 05:54:54 PDT 2022


zjaffal created this revision.
Herald added a project: All.
zjaffal added a reviewer: fhahn.
zjaffal published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Given a zero initialised variable iterating through an array and multiplying its elements, the optimiser should be able to remove the loop safely and return the initial value because fast math flags are enabled.

  double arr_d[1000];
  double f_prod = 0;
  for (size_t i = 0; i < 1000; i++){
    f_prod *= arr_d[i];
  }

The loop here can be deleted and we can return `f_prod` instead


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131757

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131757.452124.patch
Type: text/x-patch
Size: 12264 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220812/b0c8482b/attachment.bin>


More information about the llvm-commits mailing list