diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-10-14 19:46:31 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-10-14 19:46:31 +0000 |
commit | 72b5ff646d70bc799f16b5c65aca6a69cf484ee8 (patch) | |
tree | 6c3044779123887bea4af04c6d19ca03ea692304 /llvm/lib/CodeGen | |
parent | 09c2bd6bd42acb172e847d5088014512e97b37f8 (diff) | |
download | bcm5719-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.cpp | 5 |
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)); } } |