llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Suboptimal IR generation for shift left with builtin_assume

Open komalon1 opened this issue 4 years ago • 0 comments

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.

komalon1 avatar Feb 08 '22 08:02 komalon1