From 38c97a63d415917820eac639f3c3b4b061a47f71 Mon Sep 17 00:00:00 2001 From: John Criswell Date: Wed, 11 May 2005 21:16:42 +0000 Subject: [PATCH] Added support for decomposing constant expressions containing shr and shl instructions. Review of this commit would be greatly appreciated. llvm-svn: 21876 --- lib/Target/SparcV9/SparcV9PreSelection.cpp | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/Target/SparcV9/SparcV9PreSelection.cpp b/lib/Target/SparcV9/SparcV9PreSelection.cpp index 7e801243ae3..a13019e2061 100644 --- a/lib/Target/SparcV9/SparcV9PreSelection.cpp +++ b/lib/Target/SparcV9/SparcV9PreSelection.cpp @@ -146,6 +146,30 @@ static Instruction* DecomposeConstantExpr(ConstantExpr* CE, return new SelectInst (C, S1, S2, "constantSelect", &insertBefore); } + case Instruction::Shr: { + getArg1 = CE->getOperand(0); + if (ConstantExpr* CEarg = dyn_cast(getArg1)) + getArg1 = DecomposeConstantExpr(CEarg, insertBefore); + getArg2 = CE->getOperand(1); + if (ConstantExpr* CEarg = dyn_cast(getArg2)) + getArg2 = DecomposeConstantExpr(CEarg, insertBefore); + return new ShiftInst (static_cast(CE->getOpcode()), + getArg1, getArg2, + "constantShr:" + getArg1->getName(), &insertBefore); + } + + case Instruction::Shl: { + getArg1 = CE->getOperand(0); + if (ConstantExpr* CEarg = dyn_cast(getArg1)) + getArg1 = DecomposeConstantExpr(CEarg, insertBefore); + getArg2 = CE->getOperand(1); + if (ConstantExpr* CEarg = dyn_cast(getArg2)) + getArg2 = DecomposeConstantExpr(CEarg, insertBefore); + return new ShiftInst (static_cast(CE->getOpcode()), + getArg1, getArg2, + "constantShl:" + getArg1->getName(), &insertBefore); + } + default: // must be a binary operator assert(CE->getOpcode() >= Instruction::BinaryOpsBegin && CE->getOpcode() < Instruction::BinaryOpsEnd &&