This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Handle the constant with many trailing ones.
AbandonedPublic

Authored by Esme on Sep 30 2020, 1:25 AM.

Details

Reviewers
jsji
nemanjai
steven.zhang
lkail
shchenz
qiucf
Group Reviewers
Restricted Project
Summary

We have handled the constants with many trailing zeros like i64 5228199936 ( 0b100110111101000000000000000000000) , which can be materialized by 2 instructions:

	li 3, 2493
	sldi 3, 3, 21

Inspired by this, we considered another case where the constant has many trailing ones. We can take advantage of li/lis's sign-extension to generate leading ones, and then mask extra bits off after rotation.
For example, without such ISEL pattern we need 4 instructions to materialize i64 10460594175 (0b1001101111011111111111111111111111)

	li 3, 2
	sldi 3, 3, 32
	oris 3, 3, 28543
	ori 3, 3, 65535

Now we only need 2 instructions after this patch:

	li 3, -31522
	rldicl 3, 3, 23, 30

Diff Detail

Event Timeline

Esme created this revision.Sep 30 2020, 1:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 30 2020, 1:25 AM
Esme requested review of this revision.Sep 30 2020, 1:25 AM
steven.zhang added inline comments.Oct 10 2020, 1:22 AM
llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
906

selectI64ImmInstrCount need to be updated to return 2 for your pattern.

Esme planned changes to this revision.Nov 13 2020, 12:43 AM
Esme abandoned this revision.Nov 25 2020, 6:03 PM

The patch D92089 can cover this.