[llvm] r277610 - [ARM] Constant Materialize: imms with specific value can be encoded into mov.w
Weiming Zhao via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 3 10:05:23 PDT 2016
Author: weimingz
Date: Wed Aug 3 12:05:23 2016
New Revision: 277610
URL: http://llvm.org/viewvc/llvm-project?rev=277610&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
llvm/trunk/test/CodeGen/ARM/subtarget-no-movt.ll
Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=277610&r1=277609&r2=277610&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Aug 3 12:05:23 2016
@@ -476,7 +476,9 @@ bool ARMDAGToDAGISel::isShifterOpProfita
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
Modified: llvm/trunk/test/CodeGen/ARM/subtarget-no-movt.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/subtarget-no-movt.ll?rev=277610&r1=277609&r2=277610&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/subtarget-no-movt.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/subtarget-no-movt.ll Wed Aug 3 12:05:23 2016
@@ -42,4 +42,21 @@ define i32 @foo1(i32 %a) {
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" }
More information about the llvm-commits
mailing list