summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAnton Korobeynikov <anton@korobeynikov.info>2019-01-09 13:03:01 +0000
committerAnton Korobeynikov <anton@korobeynikov.info>2019-01-09 13:03:01 +0000
commitc18e90369d313932cb50446baf38c2f85ed72e40 (patch)
tree507ef4de50fea81006a893dd24e28575ab9f41c7 /llvm/lib
parent2b0094b0514348feaf67c9e56bd24c307b93e9ca (diff)
downloadbcm5719-llvm-c18e90369d313932cb50446baf38c2f85ed72e40.tar.gz
bcm5719-llvm-c18e90369d313932cb50446baf38c2f85ed72e40.zip
[MSP430] Optimize 'shl x, 8[+ N] -> swpb(zext(x)) [<< N]' for i16
Perform additional simplification to reduce shift amount. Patch by Kristina Bessonova! Differential Revision: https://reviews.llvm.org/D56016 llvm-svn: 350712
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/MSP430/MSP430ISelLowering.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp b/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
index 3df1f7b9a78..3e706134afc 100644
--- a/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
+++ b/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
@@ -954,15 +954,26 @@ SDValue MSP430TargetLowering::LowerShifts(SDValue Op,
// Expand the stuff into sequence of shifts.
SDValue Victim = N->getOperand(0);
- if ((Opc == ISD::SRA || Opc == ISD::SRL) && ShiftAmount >= 8) {
- // foo >> (8 + N) => sxt(swpb(foo)) >> N
+ if (ShiftAmount >= 8) {
assert(VT == MVT::i16 && "Can not shift i8 by 8 and more");
- Victim = DAG.getNode(ISD::BSWAP, dl, VT, Victim);
- if (Opc == ISD::SRA)
- Victim = DAG.getNode(ISD::SIGN_EXTEND_INREG, dl, VT, Victim,
- DAG.getValueType(MVT::i8));
- else
+ switch(Opc) {
+ default:
+ llvm_unreachable("Unknown shift");
+ case ISD::SHL:
+ // foo << (8 + N) => swpb(zext(foo)) << N
Victim = DAG.getZeroExtendInReg(Victim, dl, MVT::i8);
+ Victim = DAG.getNode(ISD::BSWAP, dl, VT, Victim);
+ break;
+ case ISD::SRA:
+ case ISD::SRL:
+ // foo >> (8 + N) => sxt(swpb(foo)) >> N
+ Victim = DAG.getNode(ISD::BSWAP, dl, VT, Victim);
+ Victim = (Opc == ISD::SRA)
+ ? DAG.getNode(ISD::SIGN_EXTEND_INREG, dl, VT, Victim,
+ DAG.getValueType(MVT::i8))
+ : DAG.getZeroExtendInReg(Victim, dl, MVT::i8);
+ break;
+ }
ShiftAmount -= 8;
}
OpenPOWER on IntegriCloud