[llvm] r349222 - [X86] Make hasNoCarryFlagUses/hasNoSignedComparisonUses take an SDValue that indicates which result is the flag result. NFCI
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 14 17:07:17 PST 2018
Author: ctopper
Date: Fri Dec 14 17:07:16 2018
New Revision: 349222
URL: http://llvm.org/viewvc/llvm-project?rev=349222&view=rev
Log:
[X86] Make hasNoCarryFlagUses/hasNoSignedComparisonUses take an SDValue that indicates which result is the flag result. NFCI
hasNoCarryFlagUses hardcoded that the flag result is 1 and used that to filter which uses were of interest. hasNoSignedComparisonUses just assumes the only result is flags and checks whether any user of the node is a CopyToReg instruction.
After this patch we now do a result number check in both and rely on the caller to provide the result number.
This shouldn't change behavior it was just an odd difference between the two functions that I noticed.
Modified:
llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=349222&r1=349221&r2=349222&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Fri Dec 14 17:07:16 2018
@@ -2193,16 +2193,16 @@ bool X86DAGToDAGISel::isSExtAbsoluteSymb
/// Test whether the given X86ISD::CMP node has any uses which require the SF
/// or OF bits to be accurate.
-static bool hasNoSignedComparisonUses(SDNode *N) {
+static bool hasNoSignedComparisonUses(SDValue Flags) {
// Examine each user of the node.
- for (SDNode::use_iterator UI = N->use_begin(),
- UE = N->use_end(); UI != UE; ++UI) {
- // Only examine CopyToReg uses.
- if (UI->getOpcode() != ISD::CopyToReg)
- return false;
+ for (SDNode::use_iterator UI = Flags->use_begin(), UE = Flags->use_end();
+ UI != UE; ++UI) {
+ // Only check things that use the flags.
+ if (UI.getUse().getResNo() != Flags.getResNo())
+ continue;
// Only examine CopyToReg uses that copy to EFLAGS.
- if (cast<RegisterSDNode>(UI->getOperand(1))->getReg() !=
- X86::EFLAGS)
+ if (UI->getOpcode() != ISD::CopyToReg ||
+ cast<RegisterSDNode>(UI->getOperand(1))->getReg() != X86::EFLAGS)
return false;
// Examine each user of the CopyToReg use.
for (SDNode::use_iterator FlagUI = UI->use_begin(),
@@ -2255,18 +2255,16 @@ static bool hasNoSignedComparisonUses(SD
/// Test whether the given node which sets flags has any uses which require the
/// CF flag to be accurate.
-static bool hasNoCarryFlagUses(SDNode *N) {
+static bool hasNoCarryFlagUses(SDValue Flags) {
// Examine each user of the node.
- for (SDNode::use_iterator UI = N->use_begin(), UE = N->use_end(); UI != UE;
- ++UI) {
+ for (SDNode::use_iterator UI = Flags->use_begin(), UE = Flags->use_end();
+ UI != UE; ++UI) {
// Only check things that use the flags.
- if (UI.getUse().getResNo() != 1)
+ if (UI.getUse().getResNo() != Flags.getResNo())
continue;
- // Only examine CopyToReg uses.
- if (UI->getOpcode() != ISD::CopyToReg)
- return false;
// Only examine CopyToReg uses that copy to EFLAGS.
- if (cast<RegisterSDNode>(UI->getOperand(1))->getReg() != X86::EFLAGS)
+ if (UI->getOpcode() != ISD::CopyToReg ||
+ cast<RegisterSDNode>(UI->getOperand(1))->getReg() != X86::EFLAGS)
return false;
// Examine each user of the CopyToReg use.
for (SDNode::use_iterator FlagUI = UI->use_begin(), FlagUE = UI->use_end();
@@ -2631,7 +2629,7 @@ bool X86DAGToDAGISel::foldLoadStoreIntoM
(-OperandV).getMinSignedBits() <= 8) ||
(MemVT == MVT::i64 && OperandV.getMinSignedBits() > 32 &&
(-OperandV).getMinSignedBits() <= 32)) &&
- hasNoCarryFlagUses(StoredVal.getNode())) {
+ hasNoCarryFlagUses(StoredVal.getValue(1))) {
OperandV = -OperandV;
Opc = Opc == X86ISD::ADD ? X86ISD::SUB : X86ISD::ADD;
}
@@ -3717,7 +3715,7 @@ void X86DAGToDAGISel::Select(SDNode *Nod
if (isUInt<8>(Mask) &&
(!(Mask & 0x80) || CmpVT == MVT::i8 ||
- hasNoSignedComparisonUses(Node))) {
+ hasNoSignedComparisonUses(SDValue(Node, 0)))) {
// For example, convert "testl %eax, $8" to "testb %al, $8"
VT = MVT::i8;
SubRegOp = X86::sub_8bit;
@@ -3725,7 +3723,7 @@ void X86DAGToDAGISel::Select(SDNode *Nod
MOpc = X86::TEST8mi;
} else if (OptForMinSize && isUInt<16>(Mask) &&
(!(Mask & 0x8000) || CmpVT == MVT::i16 ||
- hasNoSignedComparisonUses(Node))) {
+ hasNoSignedComparisonUses(SDValue(Node, 0)))) {
// For example, "testl %eax, $32776" to "testw %ax, $32776".
// NOTE: We only want to form TESTW instructions if optimizing for
// min size. Otherwise we only save one byte and possibly get a length
@@ -3739,7 +3737,8 @@ void X86DAGToDAGISel::Select(SDNode *Nod
// Without minsize 16-bit Cmps can get here so we need to
// be sure we calculate the correct sign flag if needed.
(CmpVT != MVT::i16 || !(Mask & 0x8000))) ||
- CmpVT == MVT::i32 || hasNoSignedComparisonUses(Node))) {
+ CmpVT == MVT::i32 ||
+ hasNoSignedComparisonUses(SDValue(Node, 0)))) {
// For example, "testq %rax, $268468232" to "testl %eax, $268468232".
// NOTE: We only want to run that transform if N0 is 32 or 64 bits.
// Otherwize, we find ourselves in a position where we have to do
More information about the llvm-commits
mailing list