From e1fd05ebde0de282c4eb7abde9a32d1beec356e7 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 25 Oct 2005 19:32:37 +0000 Subject: [PATCH] Fix a couple of minor bugs. The first fixes povray, the second fixes things if the dag combiner isn't run llvm-svn: 23981 --- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp index 336c2b154086..7b3227dcaa8e 100644 --- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -898,8 +898,11 @@ SDOperand PPCDAGToDAGISel::Select(SDOperand Op) { Tmp = CurDAG->getTargetNode(PPC::ADDIS, MVT::i32, getGlobalBaseReg(),CPI); else Tmp = CurDAG->getTargetNode(PPC::LIS, MVT::i32, CPI); - CurDAG->SelectNodeTo(N, PPC::LA, MVT::i32, Tmp, CPI); - return SDOperand(N, 0); + if (N->hasOneUse()) { + CurDAG->SelectNodeTo(N, PPC::LA, MVT::i32, Tmp, CPI); + return SDOperand(N, 0); + } + return CurDAG->getTargetNode(PPC::LA, MVT::i32, Tmp, CPI); } case ISD::GlobalAddress: { GlobalValue *GV = cast(N)->getGlobal(); @@ -1035,7 +1038,10 @@ SDOperand PPCDAGToDAGISel::Select(SDOperand Op) { unsigned SH, MB, ME; if (isRotateAndMask(N->getOperand(0).Val, Imm, false, SH, MB, ME)) { Val = Select(N->getOperand(0).getOperand(0)); - } else { + } else if (Imm == 0) { + // AND X, 0 -> 0, not "rlwinm 32". + return Select(N->getOperand(1)); + } else { Val = Select(N->getOperand(0)); isRunOfOnes(Imm, MB, ME); SH = 0;