[PATCH] D15213: [SimplifyCFG] allow speculation of exactly one expensive instruction (PR24818)

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 3 15:13:12 PST 2015


spatel created this revision.
spatel added reviewers: hfinkel, reames, jmolloy.
spatel added a subscriber: llvm-commits.

This is the last general step to allow more IR-level speculation with a safety harness in place in CodeGenPrepare. 

The intent is to restore the behavior enabled by:
http://reviews.llvm.org/rL228826

but prevent bad performance such as:
https://llvm.org/bugs/show_bug.cgi?id=24818

Earlier patches in this sequence:
D12882 (disable SimplifyCFG speculation for expensive instructions)
D13297 (have CGP despeculate expensive ops)
D14630 (have CGP despeculate special versions of cttz/ctlz)

As shown in the test cases, we only have two instructions currently affected: ctz for some x86 and fdiv generally. Allowing exactly one expensive instruction is a bit of a hack, but it lines up with what is currently implemented in CGP. If we make the despeculation more general in CGP, we can make the speculation here more liberal.

A follow-up patch will adjust the cost for sqrt and possibly other typically expensive math intrinsics (currently everything is cheap by default). GPU targets would likely want to override those expensive default costs (just as they probably should already override the cost of div/rem) because just about any math is cheaper than control-flow on those targets.

http://reviews.llvm.org/D15213

Files:
  lib/Transforms/Utils/SimplifyCFG.cpp
  test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll
  test/Transforms/SimplifyCFG/speculate-math.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15213.41806.patch
Type: text/x-patch
Size: 5977 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151203/7b12daf1/attachment.bin>


More information about the llvm-commits mailing list