From 0949ed5412c0902113aaefe106fed5b383fcc696 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 12 May 2006 16:29:37 +0000 Subject: [PATCH] Fix PowerPC/2006-05-12-rlwimi-crash.ll Nate, please verify that if InsertMask is 0, rlwimi shouldn't be used. This fixes the crash and causes no PPC testsuite regressions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28243 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/PowerPC/PPCISelDAGToDAG.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/lib/Target/PowerPC/PPCISelDAGToDAG.cpp index 2e00818b0cf..715fc420d78 100644 --- a/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -365,7 +365,7 @@ static bool isRotateAndMask(SDNode *N, unsigned Mask, bool IsShiftMask, // if the mask doesn't intersect any Indeterminant bits if (Mask && !(Mask & Indeterminant)) { - SH = Shift; + SH = Shift & 31; // make sure the mask is still a mask (wrap arounds may not be) return isRunOfOnes(Mask, MB, ME); } @@ -431,7 +431,7 @@ SDNode *PPCDAGToDAGISel::SelectBitfieldInsert(SDNode *N) { } unsigned MB, ME; - if (isRunOfOnes(InsertMask, MB, ME)) { + if (InsertMask && isRunOfOnes(InsertMask, MB, ME)) { SDOperand Tmp1, Tmp2, Tmp3; bool DisjointMask = (TargetMask ^ InsertMask) == 0xFFFFFFFF; @@ -454,6 +454,7 @@ SDNode *PPCDAGToDAGISel::SelectBitfieldInsert(SDNode *N) { Tmp3 = (Op0Opc == ISD::AND && DisjointMask) ? Op0.getOperand(0) : Op0; Select(Tmp1, Tmp3); Select(Tmp2, Op1); + SH &= 31; return CurDAG->getTargetNode(PPC::RLWIMI, MVT::i32, Tmp1, Tmp2, getI32Imm(SH), getI32Imm(MB), getI32Imm(ME)); } @@ -1149,7 +1150,7 @@ void PPCDAGToDAGISel::Select(SDOperand &Result, SDOperand Op) { SDOperand Val; Select(Val, N->getOperand(0).getOperand(0)); Result = CurDAG->SelectNodeTo(N, PPC::RLWINM, MVT::i32, - Val, getI32Imm(SH & 0x1F), getI32Imm(MB), + Val, getI32Imm(SH), getI32Imm(MB), getI32Imm(ME)); return; }