[PATCH] D57671: [ARM] Mark 255 and 65535 as cheap for Thumb1 "And"
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 4 03:58:53 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353040: [ARM] Mark 255 and 65535 as cheap for Thumb1 "And" (authored by dmgreen, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D57671?vs=184997&id=185022#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57671/new/
https://reviews.llvm.org/D57671
Files:
llvm/trunk/lib/Target/ARM/ARMTargetTransformInfo.cpp
llvm/trunk/test/CodeGen/Thumb/uxth.ll
Index: llvm/trunk/lib/Target/ARM/ARMTargetTransformInfo.cpp
===================================================================
--- llvm/trunk/lib/Target/ARM/ARMTargetTransformInfo.cpp
+++ llvm/trunk/lib/Target/ARM/ARMTargetTransformInfo.cpp
@@ -106,9 +106,13 @@
Idx == 1)
return 0;
- if (Opcode == Instruction::And)
- // Conversion to BIC is free, and means we can use ~Imm instead.
- return std::min(getIntImmCost(Imm, Ty), getIntImmCost(~Imm, Ty));
+ if (Opcode == Instruction::And) {
+ // UXTB/UXTH
+ if (Imm == 255 || Imm == 65535)
+ return 0;
+ // Conversion to BIC is free, and means we can use ~Imm instead.
+ return std::min(getIntImmCost(Imm, Ty), getIntImmCost(~Imm, Ty));
+ }
if (Opcode == Instruction::Add)
// Conversion to SUB is free, and means we can use -Imm instead.
Index: llvm/trunk/test/CodeGen/Thumb/uxth.ll
===================================================================
--- llvm/trunk/test/CodeGen/Thumb/uxth.ll
+++ llvm/trunk/test/CodeGen/Thumb/uxth.ll
@@ -68,24 +68,18 @@
define void @uxth_loop_2(i32* %a, i32 %n) {
; V6M-LABEL: uxth_loop_2:
-; V6M: .save {r4, r5, r7, lr}
-; V6M-NEXT: push {r4, r5, r7, lr}
-; V6M-NEXT: movs r3, #0
-; V6M-NEXT: ldr r2, .LCPI5_0
+; V6M: .save {r4, lr}
+; V6M-NEXT: push {r4, lr}
+; V6M-NEXT: movs r2, #0
; V6M-NEXT: .LBB5_1:
-; V6M-NEXT: adds r4, r3, #1
-; V6M-NEXT: ands r3, r2
-; V6M-NEXT: ldr r5, [r0]
-; V6M-NEXT: ands r5, r2
-; V6M-NEXT: muls r5, r3, r5
-; V6M-NEXT: stm r0!, {r5}
-; V6M-NEXT: cmp r1, r4
-; V6M-NEXT: mov r3, r4
+; V6M-NEXT: uxth r3, r2
+; V6M-NEXT: ldrh r4, [r0]
+; V6M-NEXT: muls r4, r3, r4
+; V6M-NEXT: stm r0!, {r4}
+; V6M-NEXT: adds r2, r2, #1
+; V6M-NEXT: cmp r1, r2
; V6M-NEXT: bne .LBB5_1
-; V6M-NEXT: pop {r4, r5, r7, pc}
-; V6M-NEXT: .p2align 2
-; V6M-NEXT: .LCPI5_0:
-; V6M-NEXT: .long 65535
+; V6M-NEXT: pop {r4, pc}
entry:
br label %for.body
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57671.185022.patch
Type: text/x-patch
Size: 1997 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190204/f4062950/attachment.bin>
More information about the llvm-commits
mailing list