llvm.org GIT mirror llvm / b215776
In X86DAGToDAGISel::MatchWrapper, if base or index are set, avoid matching only if symbolic addresses are RIP relatives. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68924 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 10 years ago
3 changed file(s) with 25 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
786786 bool is64Bit = Subtarget->is64Bit();
787787 DOUT << "Wrapper: 64bit " << is64Bit;
788788 DOUT << " AM "; DEBUG(AM.dump()); DOUT << "\n";
789
789790 // Under X86-64 non-small code model, GV (and friends) are 64-bits.
790 // Also, base and index reg must be 0 in order to use rip as base.
791 if (is64Bit && (TM.getCodeModel() != CodeModel::Small ||
792 AM.Base.Reg.getNode() || AM.IndexReg.getNode()))
791 if (is64Bit && (TM.getCodeModel() != CodeModel::Small))
793792 return true;
793
794 // Base and index reg must be 0 in order to use rip as base.
795 bool canUsePICRel = !AM.Base.Reg.getNode() && !AM.IndexReg.getNode();
796 if (is64Bit && !canUsePICRel && TM.symbolicAddressesAreRIPRel())
797 return true;
798
794799 if (AM.hasSymbolicDisplacement())
795800 return true;
796801 // If value is available in a register both base and index components have
0 ; RUN: llvm-as < %s | llc -mtriple=x86_64-unknown-linux-gnu -march=x86-64 -relocation-model=static -code-model=small > %t
1 ; RUN: grep leaq %t | count 1
2
3 @dst = external global [131072 x i32]
4 @ptr = external global i32*
5
6 define void @off01(i64 %i) nounwind {
7 entry:
8 %.sum = add i64 %i, 16
9 %0 = getelementptr [131072 x i32]* @dst, i64 0, i64 %.sum
10 store i32* %0, i32** @ptr, align 8
11 ret void
12 }
4242 ; RUN: grep movl %t | count 91
4343 ; RUN: not grep addl %t
4444 ; RUN: not grep subl %t
45 ; RUN: grep leaq %t | count 93
45 ; RUN: grep leaq %t | count 70
4646 ; RUN: grep movq %t | count 56
4747 ; RUN: grep addq %t | count 20
4848 ; RUN: grep subq %t | count 14
5656 ; RUN: not grep @PLT %t
5757 ; RUN: not grep @PLTOFF %t
5858 ; RUN: grep {call \\\*} %t | count 10
59 ; RUN: grep {%rip} %t | count 162
59 ; RUN: grep {%rip} %t | count 139
6060 ; RUN: llvm-as < %s | llc -mtriple=x86_64-unknown-linux-gnu -march=x86-64 -relocation-model=pic -code-model=small > %t
6161 ; RUN: not grep leal %t
6262 ; RUN: grep movl %t | count 98
145145 ; RUN: grep movl %t | count 91
146146 ; RUN: not grep addl %t
147147 ; RUN: not grep subl %t
148 ; RUN: grep leaq %t | count 93
148 ; RUN: grep leaq %t | count 70
149149 ; RUN: grep movq %t | count 56
150150 ; RUN: grep addq %t | count 20
151151 ; RUN: grep subq %t | count 14
159159 ; RUN: not grep @PLT %t
160160 ; RUN: not grep @PLTOFF %t
161161 ; RUN: grep {call \\\*} %t | count 10
162 ; RUN: grep {%rip} %t | count 162
162 ; RUN: grep {%rip} %t | count 139
163163 ; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin -march=x86-64 -relocation-model=dynamic-no-pic -code-model=small > %t
164164 ; RUN: not grep leal %t
165165 ; RUN: grep movl %t | count 95