Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit d619aa8

Browse files
author
Weiming Zhao
committed
[ARM] Constant Materialize: imms with specific value can be encoded into mov.w
Summary: Thumb2 supports encoding immediates with specific patterns into mov.w by splatting the low 8 bits into other bytes. Reviewers: john.brawn, jmolloy Subscribers: jmolloy, aemerson, rengolin, samparker, llvm-commits Differential Revision: https://reviews.llvm.org/D23090 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277610 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 29b012c commit d619aa8

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/Target/ARM/ARMISelDAGToDAG.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,9 @@ bool ARMDAGToDAGISel::isShifterOpProfitable(const SDValue &Shift,
476476
unsigned ARMDAGToDAGISel::ConstantMaterializationCost(unsigned Val) const {
477477
if (Subtarget->isThumb()) {
478478
if (Val <= 255) return 1; // MOV
479-
if (Subtarget->hasV6T2Ops() && Val <= 0xffff) return 1; // MOVW
479+
if (Subtarget->hasV6T2Ops() &&
480+
(Val <= 0xffff || ARM_AM::getT2SOImmValSplatVal(Val) != -1))
481+
return 1; // MOVW
480482
if (Val <= 510) return 2; // MOV + ADDi8
481483
if (~Val <= 255) return 2; // MOV + MVN
482484
if (ARM_AM::isThumbImmShiftedVal(Val)) return 2; // MOV + LSL

test/CodeGen/ARM/subtarget-no-movt.ll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,21 @@ define i32 @foo1(i32 %a) {
4242
ret i32 %1
4343
}
4444

45+
; NO-OPTION-LABEL: {{_?}}foo2
46+
; NO-OPTION: mov.w r0, #-536813568
47+
; NO-OPTION-LABEL-NOT: .long
48+
49+
; USE-MOVT-LABEL: {{_?}}foo2
50+
; USE-MOVT: mov.w r0, #-536813568
51+
; USE-MOVT-NOT: .long
52+
53+
; NO-USE-MOVT-LABEL: {{_?}}foo2
54+
; NO-USE-MOVT: mov.w r0, #-536813568
55+
; NO-USE-MOVT-NOT: .long
56+
define i32 @foo2() {
57+
%1 = load i32, i32* inttoptr (i32 -536813568 to i32*) ; load from 0xe000e000
58+
ret i32 %1
59+
}
60+
61+
4562
attributes #0 = { "target-features"="+no-movt" }

0 commit comments

Comments
 (0)