[PATCH] D64390: [RISCV] Fix RISCVTTIImpl::getIntImmCost for immediates where getMinSignedBits() > 64

Alex Bradbury via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 9 03:56:06 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL365462: [RISCV] Fix RISCVTTIImpl::getIntImmCost for immediates where getMinSignedBits()… (authored by asb, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D64390?vs=208606&id=208631#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64390/new/

https://reviews.llvm.org/D64390

Files:
  llvm/trunk/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
  llvm/trunk/test/Transforms/ConstantHoisting/RISCV/immediates.ll


Index: llvm/trunk/test/Transforms/ConstantHoisting/RISCV/immediates.ll
===================================================================
--- llvm/trunk/test/Transforms/ConstantHoisting/RISCV/immediates.ll
+++ llvm/trunk/test/Transforms/ConstantHoisting/RISCV/immediates.ll
@@ -26,4 +26,13 @@
   %1 = mul i64 %a, 32767
   %2 = add i64 %1, 32767
   ret i64 %2
-}
\ No newline at end of file
+}
+
+; Check that we hoist immediates with very large values.
+define i128 @test4(i128 %a) nounwind {
+; CHECK-LABEL: test4
+; CHECK: %const = bitcast i128 12297829382473034410122878 to i128
+  %1 = add i128 %a, 12297829382473034410122878
+  %2 = add i128 %1, 12297829382473034410122878
+  ret i128 %2
+}
Index: llvm/trunk/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
===================================================================
--- llvm/trunk/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ llvm/trunk/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -71,8 +71,10 @@
     // Check immediate is the correct argument...
     if (Instruction::isCommutative(Opcode) || Idx == ImmArgIdx) {
       // ... and fits into the 12-bit immediate.
-      if (getTLI()->isLegalAddImmediate(Imm.getSExtValue()))
+      if (Imm.getMinSignedBits() <= 64 &&
+          getTLI()->isLegalAddImmediate(Imm.getSExtValue())) {
         return TTI::TCC_Free;
+      }
     }
 
     // Otherwise, use the full materialisation cost.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64390.208631.patch
Type: text/x-patch
Size: 1410 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190709/abd403b4/attachment.bin>


More information about the llvm-commits mailing list