Skip to content

Commit 749b3c5

Browse files
committed
add isPow2 precaution
1 parent 4de69b6 commit 749b3c5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/coreclr/jit/ifconversion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,12 +799,12 @@ static IntConstSelectOper MatchIntConstSelectValues(int64_t trueVal, int64_t fal
799799
{
800800
unsigned bitIndex = BitOperations::Log2((uint64_t)trueVal);
801801
assert(bitIndex > 0);
802-
if (trueVal == (int64_t(1) << bitIndex))
802+
if (isPow2((uint64_t)trueVal) && trueVal == (int64_t(1) << bitIndex))
803803
return {GT_LSH, TYP_LONG, bitIndex};
804804

805805
bitIndex = BitOperations::Log2((uint32_t)trueVal);
806806
assert(bitIndex > 0);
807-
if (trueVal == int64_t(int32_t(int32_t(1) << bitIndex)))
807+
if (isPow2((uint32_t)trueVal) && trueVal == int64_t(int32_t(int32_t(1) << bitIndex)))
808808
return {GT_LSH, TYP_INT, bitIndex};
809809
}
810810

0 commit comments

Comments
 (0)