We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 27e434a commit e9288bdCopy full SHA for e9288bd
llvm/lib/Analysis/DemandedBits.cpp
@@ -83,9 +83,16 @@ void DemandedBits::determineLiveOperandBits(
83
AB = APInt::getZero(BitWidth);
84
uint64_t LoopRange = Max - Min;
85
APInt Mask = AOut;
86
+ APInt Shifted = AOut; // AOut | (AOut << 1) | ... | (AOut << (ShiftAmnt - 1)
87
for (unsigned ShiftAmnt = 1; ShiftAmnt <= LoopRange; ShiftAmnt <<= 1) {
- APInt Shifted = ShiftF(Mask, ShiftAmnt);
88
- Mask |= Shifted;
+ if (LoopRange & ShiftAmnt) {
89
+ // Account for (LoopRange - ShiftAmnt, LoopRange]
90
+ Mask |= ShiftF(Shifted, LoopRange - ShiftAmnt + 1);
91
+ // Clears the low bit.
92
+ LoopRange -= ShiftAmnt;
93
+ }
94
+ // [0, ShiftAmnt) -> [0, ShiftAmnt * 2)
95
+ Shifted |= ShiftF(Shifted, ShiftAmnt);
96
}
97
AB = ShiftF(Mask, Min);
98
};
0 commit comments