Uh oh!
There was an error while loading. Please reload this page.
JIT: Fix GenTree::IsPow2 functions - #127615
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
BoyBaykiller
commented
Apr 30, 2026
Uh oh!
There was an error while loading. Please reload this page.
There was an assert failure in arm emitter helper func which I still had to address |
tannergooding
commented
May 1, 2026
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
EgorBo
left a comment
There was a problem hiding this comment.
runtime/src/coreclr/jit/lower.cpp
Lines 4327 to 4329 in bd9e85e
While you change the behavior of this functions to ignore upper bits, it seems like we have uses where that is not expected, we need to inspect them all and fix, otherwise you're introducing a correctness issue
EgorBo
commented
May 2, 2026
from a quick look, another instance of that in fgMorphUModToAndSub |
The problem is I am not even sure what It seems like existing callers of this function want to know if there is only a single bit set. For example the Regarding the RISCV code in lower. I am not sure it is doing what the author intended. // If 'test' is a single bit test...//if (bitOp->IsIntegralConstUnsignedPow2())
{
INT64 bit = bitOp->AsIntConCommon()->IntegralValue();
int log2 = BitOperations::Log2((UINT64)bit);
bitOp->AsIntConCommon()->SetIntegralValue(log2);
returntrue;
}The I think we should add back my |
EgorBo
commented
May 2, 2026
I think we should just use truncated value in that RISC-V path |
BoyBaykiller
commented
May 2, 2026
What's the corresponding API for getting such "truncated value"? |
* add UnsignedIntegralValue * use it from IsIntegralConstUnsignedPow2 and riscv bit-opt in lower
EgorBo
commented
May 5, 2026
/azp run Fuzzlyn |
|
Azure Pipelines successfully started running 1 pipeline(s). |
BoyBaykiller
commented
May 9, 2026
@EgorBo should be good now |
EgorBo
commented
May 10, 2026
/ba-g deadletter |
EgorBo
commented
May 10, 2026
can't merge it while build analysis is red and /ba-g is broken 😐 |
Uh oh!
There was an error while loading. Please reload this page.
`IsIntegralConstUnsignedPow2` was passing in sign extended value to `isPow2`. So it wasn't actually unsigned. For example: 1 << 31 would not be recognized as pow2. Add a `UnsignedIntegralValue` that gives the zero-extended literal. Use it in `IsIntegralConstUnsignedPow2` to fix it's impl. Also use it in `fgMorphUModToAndSub` and a place in lower.
IsIntegralConstUnsignedPow2was passing in sign extended value toisPow2. So it wasn't actually unsigned. For example: 1 << 31 would not be recognized as pow2.Add a
UnsignedIntegralValuethat gives the zero-extended literal. Use it inIsIntegralConstUnsignedPow2to fix it's impl.Also use it in
fgMorphUModToAndSuband a place in lower.