This is an archive of the discontinued LLVM Phabricator instance.

[LIR] Add CTTZ support
ClosedPublic

Authored by ychen on Dec 18 2018, 7:05 PM.

Details

Summary

Existing LIR recognizes CTLZ where shifting input variable right until it is zero. (Shift-Until-Zero idiom)

This commit:

  1. Augments Shift-Until-Zero idiom to recognize CTTZ where input variable is shifted left.
  2. Prepare for BitScan idiom recognition.

Diff Detail

Event Timeline

ychen created this revision.Dec 18 2018, 7:05 PM
ychen edited the summary of this revision. (Show Details)Dec 18 2018, 7:12 PM
ychen edited the summary of this revision. (Show Details)
craig.topper added inline comments.Dec 20 2018, 1:15 PM
lib/Transforms/Scalar/LoopIdiomRecognize.cpp
1624

Can you add a test case for CntPhiUsedOutsideLoop==true with shl?

test/Transforms/LoopIdiom/X86/cttz.ll
27

Drop the absolute value. Its not necessary. It was only in the existing tests to make ashr work correctly.

ychen updated this revision to Diff 179159.Dec 20 2018, 2:32 PM

update test

ychen marked 2 inline comments as done.Dec 20 2018, 2:33 PM
ychen updated this revision to Diff 179161.Dec 20 2018, 2:40 PM
  • [LIR] Add CTTZ support part2
This revision is now accepted and ready to land.Dec 20 2018, 5:38 PM

Hi Craig, could you please help to commit it? Thanks.

This revision was automatically updated to reflect the committed changes.