diff options
author | Craig Topper <craig.topper@gmail.com> | 2019-10-27 00:41:00 -0700 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2019-10-27 10:07:15 -0700 |
commit | 73f255b83ad77f6d10bc319592f04bbd8461bbcf (patch) | |
tree | 93da47db243a5f19d4f17935d0720d06c76e3edd /llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | |
parent | 174967f15369fafb0c0bfc13d35963f7890b2c8b (diff) | |
download | bcm5719-llvm-73f255b83ad77f6d10bc319592f04bbd8461bbcf.tar.gz bcm5719-llvm-73f255b83ad77f6d10bc319592f04bbd8461bbcf.zip |
[TargetLowering] Add getBooleanContents contents check to "SETCC (SETCC), [0|1], [EQ|NE] -> SETCC" combine.
This combine is only valid if the inner setcc produces a 0/1 result
or the inner type is MVT::i1.
I haven't seen this cause any issues, just happened to notice it
while reviewing combines in this function.
While there also fix another call to use the value type from the
SDValue for the operand instead of calling SDNode::getValueType(0).
Though its likely the use is result 0, its not guaranteed.
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 9ab1324533f..14d08b8b1f2 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -3379,7 +3379,10 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1, (Cond == ISD::SETEQ || Cond == ISD::SETNE)) { // SETCC (SETCC), [0|1], [EQ|NE] -> SETCC if (N0.getOpcode() == ISD::SETCC && - isTypeLegal(VT) && VT.bitsLE(N0.getValueType())) { + isTypeLegal(VT) && VT.bitsLE(N0.getValueType()) && + (N0.getValueType() == MVT::i1 || + getBooleanContents(N0.getOperand(0).getValueType()) == + ZeroOrOneBooleanContent)) { bool TrueWhenTrue = (Cond == ISD::SETEQ) ^ (!N1C->isOne()); if (TrueWhenTrue) return DAG.getNode(ISD::TRUNCATE, dl, VT, N0); @@ -3422,7 +3425,7 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1, } } else if (N1C->isOne() && (VT == MVT::i1 || - getBooleanContents(N0->getValueType(0)) == + getBooleanContents(N0.getValueType()) == ZeroOrOneBooleanContent)) { SDValue Op0 = N0; if (Op0.getOpcode() == ISD::TRUNCATE) |