Open johnplatts opened 2 months ago
Interesting case! Would you mind sharing where you encountered this pattern?
Interesting case! Would you mind sharing where you encountered this pattern?
I was writing a portable C++ function to perform an arithmetic right-shift of a 128-bit signed integer on targets that do not support the __int128_t/__uint128_t
types.
LLVM fails to optimize out the
@llvm.fshl.i64(i64 %shifted_hi, i64 %1, i64 1)
below (as all of the bits of%shifted_hi
are known to be equal to the MSB of%1
in the code below):The above snippet run through alive-tv and opt can be found at https://alive2.llvm.org/ce/z/dew45A.
%shifted_lo = tail call i64 @llvm.fshl.i64(i64 %shifted_hi, i64 %1, i64 1)
above can be optimized down to%shifted_hi
in the case where%shifted_hi
is equal to the result ofashr i64 %1, 63
as all of the bits of%shifted_hi
are equal to the MSB of%1
.