diff options
author | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2009-01-30 07:55:25 +0000 |
---|---|---|
committer | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2009-01-30 07:55:25 +0000 |
commit | e0ffc92508a50ede2dd6f15140e7185cb6e0bcb5 (patch) | |
tree | 1314ffaad6bd7cb2df7fb10cba7c576bf08734fd | |
parent | 7ad9b5127869e0074565ffaec489c9537c6ec467 (diff) |
Use sublw for comparison with literals instead of subwf.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63382 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/PIC16/PIC16ISelLowering.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/Target/PIC16/PIC16ISelLowering.cpp b/lib/Target/PIC16/PIC16ISelLowering.cpp index ae031bc646..83d7a3e564 100644 --- a/lib/Target/PIC16/PIC16ISelLowering.cpp +++ b/lib/Target/PIC16/PIC16ISelLowering.cpp @@ -1288,23 +1288,25 @@ SDValue PIC16TargetLowering::getPIC16Cmp(SDValue LHS, SDValue RHS, } PIC16CC = DAG.getConstant(CondCode, MVT::i8); - SDVTList VTs = DAG.getVTList (MVT::i8, MVT::Flag); // These are signed comparisons. SDValue Mask = DAG.getConstant(128, MVT::i8); if (isSignedComparison(CondCode)) { - LHS = DAG.getNode (ISD::XOR, MVT::i8, LHS, Mask); + LHS = DAG.getNode (ISD::XOR, MVT::i8, LHS, Mask); RHS = DAG.getNode (ISD::XOR, MVT::i8, RHS, Mask); } + + SDVTList VTs = DAG.getVTList (MVT::i8, MVT::Flag); // We can use a subtract operation to set the condition codes. But // we need to put one operand in memory if required. - // Nothing to do if the first operand is already a direct load and it has - // only one use. - if (! (isDirectLoad(LHS) && LHS.hasOneUse())) - // Put first operand on stack. - LHS = ConvertToMemOperand (LHS, DAG); - - SDVTList Tys = DAG.getVTList(MVT::i8, MVT::Flag); + // Nothing to do if the first operand is already a valid type (direct load + // for subwf and literal for sublw) and it is used by this operation only. + if ((LHS.getOpcode() == ISD::Constant || isDirectLoad(LHS)) + && LHS.hasOneUse()) + return DAG.getNode(PIC16ISD::SUBCC, VTs, LHS, RHS); + + // else convert the first operand to mem. + LHS = ConvertToMemOperand (LHS, DAG); return DAG.getNode(PIC16ISD::SUBCC, VTs, LHS, RHS); } |