[PATCH] D23090: [ARM] Constant Materialize: imms with specific value can be encoded into mov.w

Weiming Zhao via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 2 15:35:16 PDT 2016


weimingz created this revision.
weimingz added a subscriber: llvm-commits.
weimingz set the repository for this revision to rL LLVM.
Herald added subscribers: samparker, rengolin, aemerson.

Thumb2 supports encoding immediates with specific patterns into mov.w by splatting the low 8 bits into other bytes.

Repository:
  rL LLVM

https://reviews.llvm.org/D23090

Files:
  lib/Target/ARM/ARMISelDAGToDAG.cpp
  test/CodeGen/ARM/subtarget-no-movt.ll

Index: test/CodeGen/ARM/subtarget-no-movt.ll
===================================================================
--- test/CodeGen/ARM/subtarget-no-movt.ll
+++ test/CodeGen/ARM/subtarget-no-movt.ll
@@ -42,4 +42,21 @@
   ret i32 %1
 }
 
+; NO-OPTION-LABEL: {{_?}}foo2
+; NO-OPTION: mov.w	r0, #-536813568
+; NO-OPTION-LABEL-NOT: .long
+
+; USE-MOVT-LABEL: {{_?}}foo2
+; USE-MOVT: mov.w	r0, #-536813568
+; USE-MOVT-NOT: .long
+
+; NO-USE-MOVT-LABEL: {{_?}}foo2
+; NO-USE-MOVT: mov.w	r0, #-536813568
+; NO-USE-MOVT-NOT: .long
+define i32 @foo2() {
+  %1 = load i32, i32* inttoptr (i32 -536813568 to i32*) ; load from 0xe000e000
+  ret i32 %1
+}
+
+
 attributes #0 = { "target-features"="+no-movt" }
Index: lib/Target/ARM/ARMISelDAGToDAG.cpp
===================================================================
--- lib/Target/ARM/ARMISelDAGToDAG.cpp
+++ lib/Target/ARM/ARMISelDAGToDAG.cpp
@@ -476,7 +476,9 @@
 unsigned ARMDAGToDAGISel::ConstantMaterializationCost(unsigned Val) const {
   if (Subtarget->isThumb()) {
     if (Val <= 255) return 1;                               // MOV
-    if (Subtarget->hasV6T2Ops() && Val <= 0xffff) return 1; // MOVW
+    if (Subtarget->hasV6T2Ops() &&
+        (Val <= 0xffff || ARM_AM::getT2SOImmValSplatVal(Val) != -1))
+      return 1; // MOVW
     if (Val <= 510) return 2;                               // MOV + ADDi8
     if (~Val <= 255) return 2;                              // MOV + MVN
     if (ARM_AM::isThumbImmShiftedVal(Val)) return 2;        // MOV + LSL


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23090.66573.patch
Type: text/x-patch
Size: 1502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160802/ca3b8e62/attachment.bin>


More information about the llvm-commits mailing list