summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2019-06-19 13:58:02 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2019-06-19 13:58:02 +0000
commitc3994f77cbd59bf8b75c3a0f4f701022367b9d02 (patch)
treeabd6e6e46a35bf4e479cd2a3fbb1b94ed3f91969 /llvm/lib/CodeGen/SelectionDAG
parent26c066d66d7a3f605a612718ceff67e8f86049f2 (diff)
downloadbcm5719-llvm-c3994f77cbd59bf8b75c3a0f4f701022367b9d02.tar.gz
bcm5719-llvm-c3994f77cbd59bf8b75c3a0f4f701022367b9d02.zip
[TargetLowering] SimplifyDemandedBits SIGN_EXTEND_VECTOR_INREG -> ANY/ZERO_EXTEND_VECTOR_INREG
Simplify SIGN_EXTEND_VECTOR_INREG if the extended bits are not required/known zero. Matches what we already do for SIGN_EXTEND. llvm-svn: 363802
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index dcd8478e48b..9d457427528 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -1413,9 +1413,11 @@ bool TargetLowering::SimplifyDemandedBits(
bool IsVecInReg = Op.getOpcode() == ISD::SIGN_EXTEND_VECTOR_INREG;
// If none of the top bits are demanded, convert this into an any_extend.
- // TODO: Add SIGN_EXTEND_VECTOR_INREG - ANY_EXTEND_VECTOR_INREG fold.
- if (DemandedBits.getActiveBits() <= InBits && !IsVecInReg)
- return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::ANY_EXTEND, dl, VT, Src));
+ if (DemandedBits.getActiveBits() <= InBits)
+ return TLO.CombineTo(
+ Op, TLO.DAG.getNode(IsVecInReg ? ISD::ANY_EXTEND_VECTOR_INREG
+ : ISD::ANY_EXTEND,
+ dl, VT, Src));
APInt InDemandedBits = DemandedBits.trunc(InBits);
APInt InDemandedElts = DemandedElts.zextOrSelf(InElts);
@@ -1434,9 +1436,11 @@ bool TargetLowering::SimplifyDemandedBits(
Known = Known.sext(BitWidth);
// If the sign bit is known zero, convert this to a zero extend.
- // TODO: Add SIGN_EXTEND_VECTOR_INREG - ZERO_EXTEND_VECTOR_INREG fold.
- if (Known.isNonNegative() && !IsVecInReg)
- return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::ZERO_EXTEND, dl, VT, Src));
+ if (Known.isNonNegative())
+ return TLO.CombineTo(
+ Op, TLO.DAG.getNode(IsVecInReg ? ISD::ZERO_EXTEND_VECTOR_INREG
+ : ISD::ZERO_EXTEND,
+ dl, VT, Src));
break;
}
case ISD::ANY_EXTEND: {
OpenPOWER on IntegriCloud