[PATCH] D89952: [SelectionDAG] Fine tune CTPOP optimizations
David Zarzycki via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 22 05:38:53 PDT 2020
davezarzycki created this revision.
davezarzycki added reviewers: craig.topper, spatel, RKSimon, bkramer, fhahn, pengfei, ecnelises.
davezarzycki added a project: LLVM.
Herald added a subscriber: hiraditya.
davezarzycki requested review of this revision.
Add a TLI hook to allow SelectionDAG to fine tune the conversion of CTPOP to a chain of "x & (x - 1)" when CTPOP isn't legal. The tuning in particular needs close review. I'm sure it could be refined.
Also, I'm not an expert at LLVM, but it seems like InstCombine is missing boundary optimizations that should have been caught before SelectionDAG. In particular:
ctpop(x) > 0 --> x != 0
ctpop(x) > (any size >= element size) --> always false
ctpop(x) < (any size >= element size + 1) --> always true
Any pointers on how/where to implement the above?
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D89952
Files:
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/test/CodeGen/X86/vector-popcnt-128-ult-ugt.ll
llvm/test/CodeGen/X86/vector-popcnt-256-ult-ugt.ll
llvm/test/CodeGen/X86/vector-popcnt-512-ult-ugt.ll
More information about the llvm-commits
mailing list