llvm.org GIT mirror llvm / 0c28432
One more coalescer fix wrt deadness propagation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48837 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 12 years ago
2 changed file(s) with 52 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
553553 }
554554 }
555555
556 /// PropagateDeadness - Propagate the dead marker to the instruction which
557 /// defines the val#.
558 static void PropagateDeadness(LiveInterval &li, MachineInstr *CopyMI,
559 unsigned &LRStart, LiveIntervals *li_,
560 const TargetRegisterInfo* tri_) {
561 MachineInstr *DefMI =
562 li_->getInstructionFromIndex(li_->getDefIndex(LRStart));
563 if (DefMI && DefMI != CopyMI) {
564 int DeadIdx = DefMI->findRegisterDefOperandIdx(li.reg, false, tri_);
565 if (DeadIdx != -1) {
566 DefMI->getOperand(DeadIdx).setIsDead();
567 // A dead def should have a single cycle interval.
568 ++LRStart;
569 }
570 }
571 }
572
556573 /// ShortenDeadCopyLiveRange - Shorten a live range as it's artificially
557574 /// extended by a dead copy. Mark the last use (if any) of the val# as kill
558575 /// as ends the live range there. If there isn't another use, then this
612629 // Live-in to the function but dead. Remove it from entry live-in set.
613630 mf_->begin()->removeLiveIn(li.reg);
614631 }
615 removeRange(li, LR->start, LR->end, li_, tri_);
616632 // FIXME: Shorten intervals in BBs that reaches this BB.
617 } else {
618 // Not livein into BB.
619 MachineInstr *DefMI =
620 li_->getInstructionFromIndex(li_->getDefIndex(RemoveStart));
621 if (DefMI && DefMI != CopyMI) {
622 int DeadIdx = DefMI->findRegisterDefOperandIdx(li.reg, false, tri_);
623 if (DeadIdx != -1) {
624 DefMI->getOperand(DeadIdx).setIsDead();
625 // A dead def should have a single cycle interval.
626 ++RemoveStart;
627 }
628 }
629 removeRange(li, RemoveStart, LR->end, li_, tri_);
630 }
631
633 }
634
635 if (LR->valno->def == RemoveStart)
636 // If the def MI defines the val#, propagate the dead marker.
637 PropagateDeadness(li, CopyMI, RemoveStart, li_, tri_);
638
639 removeRange(li, RemoveStart, LR->end, li_, tri_);
632640 removeIntervalIfEmpty(li, li_, tri_);
633641 }
634642
0 ; RUN: llvm-as < %s | llc -mtriple=powerpc-apple-darwin
1
2 define i32 @t(i64 %byteStart, i32 %activeIndex) nounwind {
3 entry:
4 %tmp50 = load i32* null, align 4 ; [#uses=1]
5 %tmp5051 = zext i32 %tmp50 to i64 ; [#uses=3]
6 %tmp53 = udiv i64 %byteStart, %tmp5051 ; [#uses=1]
7 %tmp5354 = trunc i64 %tmp53 to i32 ; [#uses=1]
8 %tmp62 = urem i64 %byteStart, %tmp5051 ; [#uses=1]
9 %tmp94 = add i32 0, 1 ; [#uses=1]
10 %tmp100 = urem i32 %tmp94, 0 ; [#uses=2]
11 %tmp108 = add i32 0, %activeIndex ; [#uses=1]
12 %tmp110 = sub i32 %tmp108, 0 ; [#uses=1]
13 %tmp112 = urem i32 %tmp110, 0 ; [#uses=2]
14 %tmp122 = icmp ult i32 %tmp112, %tmp100 ; [#uses=1]
15 %iftmp.175.0 = select i1 %tmp122, i32 %tmp112, i32 %tmp100 ; [#uses=1]
16 %tmp119 = add i32 %tmp5354, 0 ; [#uses=1]
17 %tmp131 = add i32 %tmp119, %iftmp.175.0 ; [#uses=1]
18 %tmp131132 = zext i32 %tmp131 to i64 ; [#uses=1]
19 %tmp147 = mul i64 %tmp131132, %tmp5051 ; [#uses=1]
20 br i1 false, label %bb164, label %bb190
21 bb164: ; preds = %entry
22 %tmp171172 = and i64 %tmp62, 4294967295 ; [#uses=1]
23 %tmp173 = add i64 %tmp171172, %tmp147 ; [#uses=0]
24 ret i32 0
25 bb190: ; preds = %entry
26 ret i32 0
27 }