[PATCH] D69127: [DAGCombiner] widen zext of popcount based on target support
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 19 08:23:00 PDT 2019
spatel added a comment.
In D69127#1715373 <https://reviews.llvm.org/D69127#1715373>, @craig.topper wrote:
> So the assumption here is that the popcnt we choose here is the same performance as any smaller popcnt that LegalizeDAG would pick through promotion. Or near enough that its better than having 2 zexts?
Almost - we're saying that ctpop+zext is no better perf than the wider ctpop. For example, the i8 test on PPC ends up like this after promotion without this patch:
t13: i32 = and t11, Constant:i32<255>
t14: i32 = ctpop t13
t18: i64 = zero_extend t14
This patch would already have hoisted the zext ahead of the i32 ctpop in that basic example, but if we had started with this i32 code, then we'd widen to i64 ctpop because we assume it's no more expensive than i32 ctpop+zext. For the PPC examples, the zext becomes a mask op, so we eliminate that instruction.
We shouldn't be touching anything that's expanded. So for base x86, we're not going to widen an i8 op because that expansion should be cheaper than any wider expansion.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69127/new/
https://reviews.llvm.org/D69127
More information about the llvm-commits
mailing list