]> granicus.if.org Git - llvm/commit
[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)
commit8bb12b9f5edd8a59c37bcfbb46e85a1ccb8c99dd
treeb7b5da71ad4961b63135bedfa2caf9c2079f854b
parent58313a9d67cb47d6498bed26f1758d73de501dcc
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284276 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/PPCISelDAGToDAG.cpp
test/CodeGen/PowerPC/pr30640.ll [new file with mode: 0644]