Page MenuHomePhabricator

[PowerPC] Exploit the rldicl + rldicr when "and" with constant
Changes PlannedPublic

Authored by steven.zhang on Dec 26 2019, 2:49 AM.

Details

Reviewers
jsji
nemanjai
shchenz
hfinkel
Group Reviewers
Restricted Project
Summary

If it is "and" with constant, for some special pattern, we could use the rotate and instructions instead of the "andi." which requires us to generate the mask using several instructions. i.e. If the mask looks like this. That is, it has two groups of ones, and either the number of leading zeroes or trailing zeroes is zero.

//     MB  MB2    ME2    ME      
// +----------------------+ 
// |0001111100000011111111| 
// +----------------------+ 
//  0          32        64

We could optimize it as follows:

  1. Rotate left MB2 + 1 bits and then, clear the bits (MB2, ME2)
    MB  MB2    ME2    ME        MB  MB2    ME2    ME
+----------------------+    +----------------------+
|1111111111111111111111| -> |0000001111111111111111+
+----------------------+    +----------------------+
 0          32        64     0          32        64
  1. Rotate back and then, clear the bits [0, MB)
    MB  MB2    ME2    ME        MB  MB2    ME2    ME
+----------------------+    +----------------------+
|0000001111111111111111| -> |0001111100000011111111+
+----------------------+    +----------------------+
 0          32        64     0          32        64

Diff Detail