llvm.org GIT mirror llvm / 1acb29c
Fix a testcase provided by Bill in which the node id could end up being wrong mostly because of forgetting to remap new nodes that morphed into processed nodes through CSE. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58323 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan Sands 11 years ago
3 changed file(s) with 50 addition(s) and 32 deletion(s). Raw diff Collapse all Expand all
221221 /// new nodes. Correct any processed operands (this may change the node) and
222222 /// calculate the NodeId.
223223 /// Returns the potentially changed node.
224 SDNode *DAGTypeLegalizer::AnalyzeNewNode(SDNode *N) {
224 void DAGTypeLegalizer::AnalyzeNewNode(SDValue &Val) {
225 SDNode *N = Val.getNode();
226
225227 // If this was an existing node that is already done, we're done.
226228 if (N->getNodeId() != NewNode)
227 return N;
229 return;
228230
229231 // Remove any stale map entries.
230232 ExpungeNode(N);
248250
249251 if (Op.getNode()->getNodeId() == Processed)
250252 RemapNode(Op);
251
252 if (Op.getNode()->getNodeId() == NewNode)
253 else if (Op.getNode()->getNodeId() == NewNode)
253254 AnalyzeNewNode(Op);
254 else if (Op.getNode()->getNodeId() == Processed)
255
256 if (Op.getNode()->getNodeId() == Processed)
255257 ++NumProcessed;
256258
257259 if (!NewOps.empty()) {
266268 }
267269
268270 // Some operands changed - update the node.
269 if (!NewOps.empty())
270 N = DAG.UpdateNodeOperands(SDValue(N, 0),
271 &NewOps[0],
272 NewOps.size()).getNode();
273
274 // Calculate the NodeId if we haven't morphed into an existing node for
275 // which it is already known.
276 if (N->getNodeId() == NewNode) {
277 N->setNodeId(N->getNumOperands()-NumProcessed);
278 if (N->getNodeId() == ReadyToProcess)
279 Worklist.push_back(N);
280 }
281
282 return N;
283 }
284
285 /// AnalyzeNewNode - call AnalyzeNewNode(SDNode *N)
286 /// and update the node in SDValue if necessary.
287 void DAGTypeLegalizer::AnalyzeNewNode(SDValue &Val) {
288 SDNode *N(Val.getNode());
289 SDNode *M(AnalyzeNewNode(N));
290 if (N != M)
291 Val.setNode(M);
271 if (!NewOps.empty()) {
272 Val = DAG.UpdateNodeOperands(Val, &NewOps[0], NewOps.size());
273 if (Val.getNode() != N) {
274 // The node morphed, work with the new node.
275 N = Val.getNode();
276
277 // Maybe it morphed into a previously analyzed node?
278 if (N->getNodeId() != NewNode) {
279 if (N->getNodeId() == Processed)
280 // An already processed node may need to be remapped.
281 RemapNode(Val);
282 return;
283 }
284
285 // It morphed into a different new node. Do the equivalent of passing
286 // it to AnalyzeNewNode: expunge it and calculate the NodeId.
287 ExpungeNode(N);
288 }
289 }
290
291 // Calculate the NodeId.
292 N->setNodeId(N->getNumOperands()-NumProcessed);
293 if (N->getNodeId() == ReadyToProcess)
294 Worklist.push_back(N);
292295 }
293296
294297
352355 // If expansion produced new nodes, make sure they are properly marked.
353356 ExpungeNode(From);
354357
355 To = AnalyzeNewNode(To); // Expunges To.
358 SDValue Val(To, 0);
359 AnalyzeNewNode(Val); // Expunges To. FIXME: All results mapped the same?
360 To = Val.getNode();
356361
357362 assert(From->getNumValues() == To->getNumValues() &&
358363 "Node results don't match");
381386 RemapNode(I->second);
382387 N = I->second;
383388 }
389 assert(N.getNode()->getNodeId() != NewNode && "Mapped to unanalyzed node!");
384390 }
385391
386392 /// ExpungeNode - If N has a bogus mapping in ReplacedNodes, eliminate it.
154154
155155 /// ReanalyzeNode - Recompute the NodeID and correct processed operands
156156 /// for the specified node, adding it to the worklist if ready.
157 SDNode *ReanalyzeNode(SDNode *N) {
157 void ReanalyzeNode(SDNode *N) {
158158 N->setNodeId(NewNode);
159 return AnalyzeNewNode(N);
159 SDValue Val(N, 0);
160 AnalyzeNewNode(Val);
161 // The node may have changed but we don't care.
160162 }
161163
162164 void NoteDeletion(SDNode *Old, SDNode *New) {
168170
169171 private:
170172 void AnalyzeNewNode(SDValue &Val);
171 SDNode *AnalyzeNewNode(SDNode *N);
172173
173174 void ReplaceValueWith(SDValue From, SDValue To);
174175 void ReplaceNodeWith(SDNode *From, SDNode *To);
0 ; RUN: llvm-as < %s | llc -march=ppc64
1
2 define void @__divtc3({ ppc_fp128, ppc_fp128 }* noalias sret %agg.result, ppc_fp128 %a, ppc_fp128 %b, ppc_fp128 %c, ppc_fp128 %d) nounwind {
3 entry:
4 %imag59 = load ppc_fp128* null, align 8 ; [#uses=1]
5 %0 = mul ppc_fp128 0xM00000000000000000000000000000000, %imag59 ; [#uses=1]
6 %1 = mul ppc_fp128 0xM00000000000000000000000000000000, 0xM00000000000000000000000000000000 ; [#uses=1]
7 %2 = add ppc_fp128 %0, %1 ; [#uses=1]
8 store ppc_fp128 %2, ppc_fp128* null, align 16
9 unreachable
10 }