-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[ValueTracking][SelectionDAG] Use KnownBits::reverseBits/byteSwap. NFC #155847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-llvm-analysis @llvm/pr-subscribers-llvm-selectiondag Author: Craig Topper (topperc) ChangesFull diff: https://github.com/llvm/llvm-project/pull/155847.diff 2 Files Affected:
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 7fe129b8456f6..e6282fc8cdbbc 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1834,13 +1834,11 @@ static void computeKnownBitsFromOperator(const Operator *I,
}
case Intrinsic::bitreverse:
computeKnownBits(I->getOperand(0), DemandedElts, Known2, Q, Depth + 1);
- Known.Zero |= Known2.Zero.reverseBits();
- Known.One |= Known2.One.reverseBits();
+ Known = Known.unionWith(Known2.reverseBits());
break;
case Intrinsic::bswap:
computeKnownBits(I->getOperand(0), DemandedElts, Known2, Q, Depth + 1);
- Known.Zero |= Known2.Zero.byteSwap();
- Known.One |= Known2.One.byteSwap();
+ Known = Known.unionWith(Known2.byteSwap());
break;
case Intrinsic::ctlz: {
computeKnownBits(I->getOperand(0), DemandedElts, Known2, Q, Depth + 1);
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 402a012e8e555..7e5844d1a8963 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -2363,8 +2363,7 @@ bool TargetLowering::SimplifyDemandedBits(
if (SimplifyDemandedBits(Src, DemandedSrcBits, DemandedElts, Known2, TLO,
Depth + 1))
return true;
- Known.One = Known2.One.reverseBits();
- Known.Zero = Known2.Zero.reverseBits();
+ Known = Known2.reverseBits();
break;
}
case ISD::BSWAP: {
@@ -2397,8 +2396,7 @@ bool TargetLowering::SimplifyDemandedBits(
if (SimplifyDemandedBits(Src, DemandedSrcBits, DemandedElts, Known2, TLO,
Depth + 1))
return true;
- Known.One = Known2.One.byteSwap();
- Known.Zero = Known2.Zero.byteSwap();
+ Known = Known2.byteSwap();
break;
}
case ISD::CTPOP: {
|
@@ -1834,13 +1834,11 @@ static void computeKnownBitsFromOperator(const Operator *I, | |||
} | |||
case Intrinsic::bitreverse: | |||
computeKnownBits(I->getOperand(0), DemandedElts, Known2, Q, Depth + 1); | |||
Known.Zero |= Known2.Zero.reverseBits(); | |||
Known.One |= Known2.One.reverseBits(); | |||
Known = Known.unionWith(Known2.reverseBits()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why isn't this Known = Known2.reverseBits()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or why isn't the abs case Known = Known.unionWith(Known2.abs(IntMinIsPoison));
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess they should all use unionWith, to take advantage of any ConstantRange info that might have been calculated before this switch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bitreverse and bswap started doing the union here ad5c2d0. abs was added later.
No description provided.