summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorMichael Liao <michael.liao@intel.com>2013-06-21 18:45:27 +0000
committerMichael Liao <michael.liao@intel.com>2013-06-21 18:45:27 +0000
commit62ebfd8786e6566b9a8abb66408920bc24cfaedf (patch)
tree31c1be87804a30d2938620f948f6b15c6aad7ac9 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent5749b8be01e33db68f5ad69541b2288553b53aa7 (diff)
downloadbcm5719-llvm-62ebfd8786e6566b9a8abb66408920bc24cfaedf.tar.gz
bcm5719-llvm-62ebfd8786e6566b9a8abb66408920bc24cfaedf.zip
Fix PR16360
When (srl (anyextend x), c) is folded into (anyextend (srl x, c)), the high bits are not cleared. Add 'and' to clear off them. llvm-svn: 184575
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index f650b4d88a3..cb9778bbd61 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3915,8 +3915,7 @@ SDValue DAGCombiner::visitSRL(SDNode *N) {
DAG.getConstant(~0ULL >> ShAmt, VT));
}
-
- // fold (srl (anyextend x), c) -> (anyextend (srl x, c))
+ // fold (srl (anyextend x), c) -> (and (anyextend (srl x, c)), mask)
if (N1C && N0.getOpcode() == ISD::ANY_EXTEND) {
// Shifting in all undef bits?
EVT SmallVT = N0.getOperand(0).getValueType();
@@ -3929,7 +3928,10 @@ SDValue DAGCombiner::visitSRL(SDNode *N) {
N0.getOperand(0),
DAG.getConstant(ShiftAmt, getShiftAmountTy(SmallVT)));
AddToWorkList(SmallShift.getNode());
- return DAG.getNode(ISD::ANY_EXTEND, SDLoc(N), VT, SmallShift);
+ APInt Mask = APInt::getAllOnesValue(VT.getSizeInBits()).lshr(ShiftAmt);
+ return DAG.getNode(ISD::AND, SDLoc(N), VT,
+ DAG.getNode(ISD::ANY_EXTEND, SDLoc(N), VT, SmallShift),
+ DAG.getConstant(Mask, VT));
}
}
OpenPOWER on IntegriCloud