[PATCH] D89341: [X86] Encode global symbol address in sub if possible
Wei Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 13 13:52:45 PDT 2020
weiwang created this revision.
Herald added subscribers: llvm-commits, wenlei, hiraditya.
Herald added a project: LLVM.
weiwang requested review of this revision.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D89341
Files:
llvm/lib/Target/X86/X86InstrCompiler.td
llvm/test/CodeGen/X86/critical-edge-split-2.ll
Index: llvm/test/CodeGen/X86/critical-edge-split-2.ll
===================================================================
--- llvm/test/CodeGen/X86/critical-edge-split-2.ll
+++ llvm/test/CodeGen/X86/critical-edge-split-2.ll
@@ -1,5 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown --code-model=medium | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown --code-model=small | FileCheck %s --check-prefix=CHECK-SMALL
%0 = type <{ %1, %1 }>
%1 = type { i8, i8, i8, i8 }
@@ -15,8 +16,9 @@
; CHECK-NEXT: testl %edi, %edi
; CHECK-NEXT: jne .LBB0_2
; CHECK-NEXT: # %bb.1: # %cond.false.i
-; CHECK-NEXT: movl $g_4, %eax
-; CHECK-NEXT: movl $g_2+4, %ecx
+; CHECK-NEXT: movabsq $g_4, %rax
+; CHECK-NEXT: movabsq $g_2, %rcx
+; CHECK-NEXT: addq $4, %rcx
; CHECK-NEXT: xorl %esi, %esi
; CHECK-NEXT: cmpq %rax, %rcx
; CHECK-NEXT: sete %sil
@@ -27,6 +29,24 @@
; CHECK-NEXT: .LBB0_2: # %cond.end.i
; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
; CHECK-NEXT: retq
+
+; CHECK-SMALL-LABEL: test1:
+; CHECK-SMALL: # %bb.0: # %entry
+; CHECK-SMALL-NEXT: movw $1, %ax
+; CHECK-SMALL-NEXT: testl %edi, %edi
+; CHECK-SMALL-NEXT: jne .LBB0_2
+; CHECK-SMALL-NEXT: # %bb.1: # %cond.false.i
+; CHECK-SMALL-NEXT: movl $g_2+4, %eax
+; CHECK-SMALL-NEXT: xorl %ecx, %ecx
+; CHECK-SMALL-NEXT: cmpq $g_4, %rax
+; CHECK-SMALL-NEXT: sete %cl
+; CHECK-SMALL-NEXT: movl $1, %eax
+; CHECK-SMALL-NEXT: xorl %edx, %edx
+; CHECK-SMALL-NEXT: divl %ecx
+; CHECK-SMALL-NEXT: movl %edx, %eax
+; CHECK-SMALL-NEXT: .LBB0_2: # %cond.end.i
+; CHECK-SMALL-NEXT: # kill: def $ax killed $ax killed $eax
+; CHECK-SMALL-NEXT: retq
entry:
br i1 %C, label %cond.end.i, label %cond.false.i
Index: llvm/lib/Target/X86/X86InstrCompiler.td
===================================================================
--- llvm/lib/Target/X86/X86InstrCompiler.td
+++ llvm/lib/Target/X86/X86InstrCompiler.td
@@ -1984,6 +1984,13 @@
def : Pat<(sub GR64:$src1, i64immSExt32:$src2),
(SUB64ri32 GR64:$src1, i64immSExt32:$src2)>;
+// sub reg, X86Wrapper
+// Adjust the complexity so that it is matched after 'sub reg, imm' patterns.
+let AddedComplexity = -3 in {
+def : Pat<(X86sub_flag GR64:$src1, mov64imm32:$src2),
+ (SUB64ri32 GR64:$src1, mov64imm32:$src2)>;
+}
+
// sub 0, reg
def : Pat<(X86sub_flag 0, GR8 :$src), (NEG8r GR8 :$src)>;
def : Pat<(X86sub_flag 0, GR16:$src), (NEG16r GR16:$src)>;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89341.297951.patch
Type: text/x-patch
Size: 2621 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201013/030653c7/attachment.bin>
More information about the llvm-commits
mailing list