[PowerPC] Collapse RLDICL/RLDICR into RLDIC when possible
authorNemanja Ivanovic <nemanja.i.ibm@gmail.com>
Wed, 5 Jun 2019 02:36:40 +0000 (02:36 +0000)
committerNemanja Ivanovic <nemanja.i.ibm@gmail.com>
Wed, 5 Jun 2019 02:36:40 +0000 (02:36 +0000)
commit7c842fadf100b2ed160986e40a9a68a0613df256
treeda5a2d10def877529cd9f745e604cd7181ec6b6d
parent44fb55bf96158ac3c9a90eae1818fb6b1ddefef6
[PowerPC] Collapse RLDICL/RLDICR into RLDIC when possible

Generally speaking, we lower to an optimal rotate sequence for nodes visible in
the SDAG. However, there are instances where the two rotates are not visible at
ISEL time - most notably those in a very common sequence when lowering switch
statements to jump tables.

A common situation is a switch on a 32-bit integer. This value has to have the
upper 32 bits cleared and because jump table offsets are word offsets, the value
needs to be shifted left by 2 bits. We currently emit the clear and the left
shift as two separate instructions, but this is not needed as we can lower it to
a single RLDIC.

This patch just cleans that up.

Differential revision: https://reviews.llvm.org/D60402

llvm-svn: 362576
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
llvm/test/CodeGen/PowerPC/collapse-rotates.mir [new file with mode: 0644]
llvm/test/CodeGen/PowerPC/jump-tables-collapse-rotate.ll [new file with mode: 0644]