llvm-project
llvm-project copied to clipboard
Suboptimal IR generation for shift left with builtin_assume
godbolt link: https://godbolt.org/z/3ao3b3P9j
Compiling the following program:
unsigned short shl(unsigned short val, unsigned char shift) {
__builtin_assume(shift < 16);
return (val << shift);
}
resulted in suboptimal IR. Since we know shift < 16 there is no need to extend all intermediate calculations to i32, it's enough to do so using i16 types.