Skip to content

Commit ecb9d94

Browse files
authored
[KnownBits] Speed up conflict handling in ForeachKnownBits in unit test. (#94943)
Exit early if known bits have a conflict. This gives me a ~15% speed up when running this in my Release+Asserts build: $ unittests/Support/SupportTests --gtest_filter=KnownBitsTest.*Exhaustive
1 parent ae9d89d commit ecb9d94

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

llvm/unittests/Support/KnownBitsTest.h

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ void ForeachNumInKnownBits(const KnownBits &Known, FnTy Fn) {
3838
unsigned Max = 1u << Bits;
3939
unsigned Zero = Known.Zero.getZExtValue();
4040
unsigned One = Known.One.getZExtValue();
41+
42+
if (Zero & One) {
43+
// Known has a conflict. No values will satisfy it.
44+
return;
45+
}
46+
4147
for (unsigned N = 0; N < Max; ++N) {
4248
if ((N & Zero) == 0 && (~N & One) == 0)
4349
Fn(APInt(Bits, N));

0 commit comments

Comments
 (0)