[PPC] Shorter sequence to load 64bit constant with same hi/lo words
authorGuozhi Wei <carrot@google.com>
Fri, 14 Oct 2016 20:41:50 +0000 (20:41 +0000)
committerGuozhi Wei <carrot@google.com>
Fri, 14 Oct 2016 20:41:50 +0000 (20:41 +0000)
commit0cd65429befcf5d39ad2e53c0e56252108982916
tree9d775dc640d42979d0e722d01a939bcfbb071d6a
parente450e40741cfb19778fdc50c6272f0f0642a65c8
[PPC] Shorter sequence to load 64bit constant with same hi/lo words

This is a patch to implement pr30640.

When a 64bit constant has the same hi/lo words, we can use rldimi to copy the low word into high word of the same register.

This optimization caused failure of test case bperm.ll because of not optimal heuristic in function SelectAndParts64. It chooses AND or ROTATE to extract bit groups from a register, and OR them together. This optimization lowers the cost of loading 64bit constant mask used in AND method, and causes different code sequence. But actually ROTATE method is better in this test case. The reason is in ROTATE method the final OR operation can be avoided since rldimi can insert the rotated bits into target register directly. So this patch also enhances SelectAndParts64 to prefer ROTATE method when the two methods have same cost and there are multiple bit groups need to be ORed together.

Differential Revision: https://reviews.llvm.org/D25521

llvm-svn: 284276
llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
llvm/test/CodeGen/PowerPC/pr30640.ll [new file with mode: 0644]