[PATCH] D89578: [CostModel] Return TCC_Expensive for non-speculatable ctlz/cttz.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 16 11:35:33 PDT 2020


fhahn created this revision.
fhahn added reviewers: RKSimon, lebedev.ri, spatel, craig.topper, samparker.
Herald added a subscriber: pengfei.
Herald added a project: LLVM.
fhahn requested review of this revision.

Before 871556a494552c0f503eec17055f075bcd859937 <https://reviews.llvm.org/rG871556a494552c0f503eec17055f075bcd859937>, we would return
TCC_Expensive for non-speculatable CTTZ/CTLZ, but the patch removed the
exit. I am not sure if that was intentional, but it seems now we also
treat un-speculatable CTLZ/CTTZ as non-expensive.

See the change in the test case. The current speculation limit in
SimplifyCFG is set so that a single expensive instruction can be
speculated, but in test9_loop and expensive and a cheap instruction
needs speculating, pushing it over the limit.

Note that currently the X86 backend considers CTTZ/CTLZ as cheap to speculate
on architectures like haswell or skylake, where it is actually quite expensive.
But that is a separate issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89578

Files:
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89578.298694.patch
Type: text/x-patch
Size: 5007 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201016/3504af51/attachment.bin>


More information about the llvm-commits mailing list