llvm.org GIT mirror llvm / 7d6d4b3
Do not fold away subreg_to_reg if the source register has a sub-register index. That means the source register is taking a sub-register of a larger register. e.g. On x86 %RAX<def> = ... %RAX<def> = SUBREG_TO_REG 0, %EAX:3<kill>, 3 The first def is defining RAX, not EAX so the top bits were not zero-extended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67511 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 10 years ago
2 changed file(s) with 34 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
164164
165165 unsigned DstReg = MI->getOperand(0).getReg();
166166 unsigned InsReg = MI->getOperand(2).getReg();
167 unsigned SubIdx = MI->getOperand(3).getImm();
167 unsigned InsSIdx = MI->getOperand(2).getSubReg();
168 unsigned SubIdx = MI->getOperand(3).getImm();
168169
169170 assert(SubIdx != 0 && "Invalid index for insert_subreg");
170171 unsigned DstSubReg = TRI.getSubReg(DstReg, SubIdx);
171
172
172173 assert(TargetRegisterInfo::isPhysicalRegister(DstReg) &&
173174 "Insert destination must be in a physical register");
174175 assert(TargetRegisterInfo::isPhysicalRegister(InsReg) &&
176177
177178 DOUT << "subreg: CONVERTING: " << *MI;
178179
179 if (DstSubReg == InsReg) {
180 if (DstSubReg == InsReg && InsSIdx == 0) {
180181 // No need to insert an identify copy instruction.
182 // Watch out for case like this:
183 // %RAX = ...
184 // %RAX = SUBREG_TO_REG 0, %EAX:3, 3
185 // The first def is defining RAX, not EAX so the top bits were not
186 // zero extended.
181187 DOUT << "subreg: eliminated!";
182188 } else {
183189 // Insert sub-register copy
0 ; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin | grep movl
1 ; rdar://6707985
2
3 %XXOO = type { %"struct.XXC::XXCC", i8*, %"struct.XXC::XXOO::$_71" }
4 %XXValue = type opaque
5 %"struct.XXC::ArrayStorage" = type { i32, i32, i32, i8*, i8*, [1 x %XXValue*] }
6 %"struct.XXC::XXArray" = type { %XXOO, i32, %"struct.XXC::ArrayStorage"* }
7 %"struct.XXC::XXCC" = type { i32 (...)**, i8* }
8 %"struct.XXC::XXOO::$_71" = type { [2 x %XXValue*] }
9
10 define internal fastcc %XXValue* @t(i64* %out, %"struct.XXC::ArrayStorage"* %tmp9) nounwind {
11 prologue:
12 %array = load %XXValue** inttoptr (i64 11111111 to %XXValue**) ; <%XXValue*> [#uses=0]
13 %index = load %XXValue** inttoptr (i64 22222222 to %XXValue**) ; <%XXValue*> [#uses=1]
14 %tmp = ptrtoint %XXValue* %index to i64 ; [#uses=2]
15 store i64 %tmp, i64* %out
16 %tmp6 = trunc i64 %tmp to i32 ; [#uses=1]
17 br label %bb5
18
19 bb5: ; preds = %prologue
20 %tmp10 = zext i32 %tmp6 to i64 ; [#uses=1]
21 %tmp11 = getelementptr %"struct.XXC::ArrayStorage"* %tmp9, i64 0, i32 5, i64 %tmp10 ; <%XXValue**> [#uses=1]
22 %tmp12 = load %XXValue** %tmp11, align 8 ; <%XXValue*> [#uses=1]
23 ret %XXValue* %tmp12
24 }