[ARM64] Never hoist the shift value of a shift instruction.
authorJuergen Ributzka <juergen@apple.com>
Sat, 12 Apr 2014 02:53:51 +0000 (02:53 +0000)
committerJuergen Ributzka <juergen@apple.com>
Sat, 12 Apr 2014 02:53:51 +0000 (02:53 +0000)
There is no need to check if we want to hoist the immediate value of an
shift instruction. Simply return TCC_Free right away.

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

lib/Target/ARM64/ARM64TargetTransformInfo.cpp
test/Transforms/ConstantHoisting/ARM64/large-immediate.ll

index cc8cc806ec7045dda11c46328aeddd1092d28001..372900e99feee1ab7ac984ce0c3d3a9ab676c7b1 100644 (file)
@@ -203,15 +203,19 @@ unsigned ARM64TTI::getIntImmCost(unsigned Opcode, unsigned Idx,
   case Instruction::SDiv:
   case Instruction::URem:
   case Instruction::SRem:
-  case Instruction::Shl:
-  case Instruction::LShr:
-  case Instruction::AShr:
   case Instruction::And:
   case Instruction::Or:
   case Instruction::Xor:
   case Instruction::ICmp:
     ImmIdx = 1;
     break;
+  // Always return TCC_Free for the shift value of a shift instruction.
+  case Instruction::Shl:
+  case Instruction::LShr:
+  case Instruction::AShr:
+    if (Idx == 1)
+      return TCC_Free;
+    break;
   case Instruction::Trunc:
   case Instruction::ZExt:
   case Instruction::SExt:
index 92ad6ee70de78374dcf3626c73fde76013827f77..575be791d9b1e170b20722e76cbe23a28be44a01 100644 (file)
@@ -16,3 +16,12 @@ define i512 @test2(i512 %a) nounwind {
   %2 = or i512 %1, 7
   ret i512 %2
 }
+
+; Check that we don't hoist the shift value of a shift instruction.
+define i512 @test3(i512 %a) nounwind {
+; CHECK-LABEL: test3
+; CHECK-NOT: %const = bitcast i512 504 to i512
+  %1 = shl i512 %a, 504
+  %2 = ashr i512 %1, 504
+  ret i512 %2
+}