This is an archive of the discontinued LLVM Phabricator instance.

[CostModel][X86] Add bool anyof/allof reduction costs
ClosedPublic

Authored by RKSimon on Apr 8 2019, 5:35 AM.

Details

Summary

On pre-AVX512 targets we can use MOVMSK to extract reduced boolean results. This is properly optimized, annoyingly AVX512 isn't and produces code that is almost as bad as the (unchanged) costs suggest......

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Apr 8 2019, 5:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2019, 5:35 AM

The patch itself looks good, can't say anything about the numbers.

spatel added inline comments.Apr 16 2019, 2:27 PM
lib/Target/X86/X86TargetTransformInfo.cpp
2493 ↗(On Diff #194121)

Add a code comment here with the expected lowering?

vpmovmskb %xmm, %eax
cmpb  $IMM, %al
2502 ↗(On Diff #194121)

Similarly:

vextractf128 %ymm0, %xmm1, 1
vpand  %xmm1, %xmm0, %xmm0 
vpmovmskb %xmm0, %eax
cmpb  $IMM, %al
2523 ↗(On Diff #194121)

Better to make this 'isIntegerTy(1)'? We should not have a vector type here?

RKSimon updated this revision to Diff 195465.Apr 16 2019, 2:41 PM

Add codegen comments and use Type::isIntegerTy(1)

RKSimon marked 3 inline comments as done.Apr 16 2019, 2:41 PM
RKSimon updated this revision to Diff 195467.Apr 16 2019, 2:49 PM

Use Type::getVectorElementType()->isIntegerTy(1) - reduction types should always be vectors

spatel accepted this revision.Apr 16 2019, 2:52 PM

LGTM

This revision is now accepted and ready to land.Apr 16 2019, 2:52 PM
This revision was automatically updated to reflect the committed changes.