[llvm] r206101 - [ARM64] Never hoist the shift value of a shift instruction.

Juergen Ributzka juergen at apple.com
Fri Apr 11 19:53:51 PDT 2014


Author: ributzka
Date: Fri Apr 11 21:53:51 2014
New Revision: 206101

URL: http://llvm.org/viewvc/llvm-project?rev=206101&view=rev
Log:
[ARM64] Never hoist the shift value of a shift instruction.

There is no need to check if we want to hoist the immediate value of an
shift instruction. Simply return TCC_Free right away.

Modified:
    llvm/trunk/lib/Target/ARM64/ARM64TargetTransformInfo.cpp
    llvm/trunk/test/Transforms/ConstantHoisting/ARM64/large-immediate.ll

Modified: llvm/trunk/lib/Target/ARM64/ARM64TargetTransformInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM64/ARM64TargetTransformInfo.cpp?rev=206101&r1=206100&r2=206101&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM64/ARM64TargetTransformInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM64/ARM64TargetTransformInfo.cpp Fri Apr 11 21:53:51 2014
@@ -203,15 +203,19 @@ unsigned ARM64TTI::getIntImmCost(unsigne
   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:

Modified: llvm/trunk/test/Transforms/ConstantHoisting/ARM64/large-immediate.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstantHoisting/ARM64/large-immediate.ll?rev=206101&r1=206100&r2=206101&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/ConstantHoisting/ARM64/large-immediate.ll (original)
+++ llvm/trunk/test/Transforms/ConstantHoisting/ARM64/large-immediate.ll Fri Apr 11 21:53:51 2014
@@ -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
+}





More information about the llvm-commits mailing list