summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-10-14 19:46:31 +0000
committerSanjay Patel <spatel@rotateright.com>2016-10-14 19:46:31 +0000
commit72b5ff646d70bc799f16b5c65aca6a69cf484ee8 (patch)
tree6c3044779123887bea4af04c6d19ca03ea692304 /llvm/lib/CodeGen
parent09c2bd6bd42acb172e847d5088014512e97b37f8 (diff)
downloadbcm5719-llvm-72b5ff646d70bc799f16b5c65aca6a69cf484ee8.tar.gz
bcm5719-llvm-72b5ff646d70bc799f16b5c65aca6a69cf484ee8.zip
[DAG] avoid creating illegal node when transforming negated shifted sign bit
Eli noted this potential bug in the post-commit thread for: https://reviews.llvm.org/rL284239 ...but I'm not sure how to trigger it, so there's no test case yet. llvm-svn: 284268
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 031edb615b8..44a49e848aa 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1962,8 +1962,9 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
(N1->getOpcode() == ISD::SRA || N1->getOpcode() == ISD::SRL)) {
ConstantSDNode *ShiftAmt = isConstOrConstSplat(N1.getOperand(1));
if (ShiftAmt && ShiftAmt->getZExtValue() == VT.getScalarSizeInBits() - 1) {
- auto NewOpcode = N1->getOpcode() == ISD::SRA ? ISD::SRL :ISD::SRA;
- return DAG.getNode(NewOpcode, DL, VT, N1.getOperand(0), N1.getOperand(1));
+ auto NewOpc = N1->getOpcode() == ISD::SRA ? ISD::SRL :ISD::SRA;
+ if (!LegalOperations || TLI.isOperationLegal(NewOpc, VT))
+ return DAG.getNode(NewOpc, DL, VT, N1.getOperand(0), N1.getOperand(1));
}
}
OpenPOWER on IntegriCloud