Page MenuHomePhabricator

[PowerPC] Add folding patterns for rlwinm + andi_rec.
Needs ReviewPublic

Authored by Esme on Oct 25 2020, 9:48 PM.

Details

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

This patch depends on D89855. We have patterns to fold RLWINM + RLWINM.
Pairs of RLWINM and ANDI_rec can also be folded in some cases.
Following is a scenario in C code:

int tmp = vec_test_swdiv(x,y);
if (((__builtin_rotateleft32(tmp, 62)) & (1)) != 0){
  ...
}

clang -c t.c -O3 generates the sequence:

xvtdivdp cr0,vs34,vs35
mfocrf  r3,128
rlwinm  r3,r3,4,28,31 --->generated in POST-RA
andi.   r3,r3,4

This patch will fold it to:

xvtdivdp cr0,vs34,vs35
mfocrf   r3,128
rlwinm.  r3,r3,4,29,29

Diff Detail

Event Timeline

Esme created this revision.Oct 25 2020, 9:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 25 2020, 9:48 PM
Esme requested review of this revision.Oct 25 2020, 9:48 PM
Esme updated this revision to Diff 307494.Tue, Nov 24, 6:46 PM
Esme edited the summary of this revision. (Show Details)
Esme updated this revision to Diff 307952.Thu, Nov 26, 7:55 PM

Added the situation of Mask == 0.

Esme planned changes to this revision.Thu, Nov 26, 10:23 PM
Esme updated this revision to Diff 308378.Mon, Nov 30, 8:22 AM

FIXME: A deg was found in llvm/test/CodeGen/PowerPC/p10-spill-crlt.ll

Esme planned changes to this revision.Mon, Nov 30, 8:23 AM
Esme updated this revision to Diff 308533.Mon, Nov 30, 9:31 PM

This is more clear than the previous version. Some implementation comments.

llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
3419

Nice catch! Then should we reuse legacy logic? If ANDI_rec mask is not runofones, we can not fold RLWINM + ANDI_rec to a single RLWINM? If ANDI_rec mask is runofones, can we treat it as special rlwinm_rec with sh = 0, and MB, ME can be got from runofones check?