[llvm] 73f255b - [TargetLowering] Add getBooleanContents contents check to "SETCC (SETCC), [0|1], [EQ|NE] -> SETCC" combine.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 27 10:26:08 PDT 2019
Author: Craig Topper
Date: 2019-10-27T10:07:15-07:00
New Revision: 73f255b83ad77f6d10bc319592f04bbd8461bbcf
URL: https://github.com/llvm/llvm-project/commit/73f255b83ad77f6d10bc319592f04bbd8461bbcf
DIFF: https://github.com/llvm/llvm-project/commit/73f255b83ad77f6d10bc319592f04bbd8461bbcf.diff
LOG: [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.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 9ab1324533f1..14d08b8b1f29 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)
More information about the llvm-commits
mailing list