AMDGPU/SI: Fix some invaild assumptions when folding 64-bit immediates
authorTom Stellard <thomas.stellard@amd.com>
Sat, 29 Aug 2015 01:58:21 +0000 (01:58 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Sat, 29 Aug 2015 01:58:21 +0000 (01:58 +0000)
Summary:
We were assuming tha if the use operand had a sub-register that
the immediate was 64-bits, but this was breaking the case of
folding a 64-bit immediate into another 64-bit instruction.

Reviewers: arsenm

Subscribers: arsenm, llvm-commits

Differential Revision: http://reviews.llvm.org/D12255

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246354 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/SIFoldOperands.cpp

index 5609f3ce2f2d2e21269586fbad67e27ecc6830b6..eff9c072f40b52ecb56d6f896efbd1b541b1da5a 100644 (file)
@@ -211,8 +211,12 @@ static void foldOperand(MachineOperand &OpToFold, MachineInstr *UseMI,
 
     Imm = APInt(64, OpToFold.getImm());
 
+    const MCInstrDesc &FoldDesc = TII->get(OpToFold.getParent()->getOpcode());
+    const TargetRegisterClass *FoldRC =
+        TRI.getRegClass(FoldDesc.OpInfo[0].RegClass);
+
     // Split 64-bit constants into 32-bits for folding.
-    if (UseOp.getSubReg()) {
+    if (FoldRC->getSize() == 8 && UseOp.getSubReg()) {
       if (UseRC->getSize() != 8)
         return;