[PATCH] D143954: [ValueTracking] It is not safe to execute FDIV/FREM speculatively

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 13 14:56:31 PST 2023


Carrot created this revision.
Herald added subscribers: wenlei, hiraditya.
Herald added a project: All.
Carrot requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.

In function isSafeToSpeculativelyExecuteWithOpcode, integer DIV/REM is marked as unsafe to execute speculatively, but floating point FDIV/FREM is not checked. They are also unsafe for the same reason.

There are some optimization regressions with this patch, such as select.ll. It is because function isSafeToSpeculativelyExecuteWithOpcode is called in several different kinds of speculations.

  1 The dest block may be executed but the src block is not executed, like the new test case, it is danger for FDIV.
  2 The src block is executed by the dest may not be executed, like select.ll, it is safe for FDIV.

In future we may split isSafeToSpeculativelyExecuteWithOpcode for different speculations to get most optimization opportunities.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143954

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Transforms/CodeGenPrepare/X86/select.ll
  llvm/test/Transforms/InstCombine/vec_shuffle-inseltpoison.ll
  llvm/test/Transforms/InstCombine/vec_shuffle.ll
  llvm/test/Transforms/PGOProfile/chr.ll
  llvm/test/Transforms/Reassociate/2019-08-22-FNegAssert.ll
  llvm/test/Transforms/Reassociate/canonicalize-neg-const.ll
  llvm/test/Transforms/SLPVectorizer/X86/crash_exceed_scheduling.ll
  llvm/test/Transforms/SLPVectorizer/X86/reuse-extracts-in-wider-vect.ll
  llvm/test/Transforms/SimplifyCFG/ARM/speculate-math.ll
  llvm/test/Transforms/SimplifyCFG/speculate-math.ll
  llvm/test/Transforms/SimplifyCFG/unsafe-speculate.ll
  llvm/test/Transforms/SpeculativeExecution/spec-fp.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143954.497115.patch
Type: text/x-patch
Size: 61379 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230213/13c54f00/attachment.bin>


More information about the llvm-commits mailing list