On Wed, Jun 23, 2021 at 09:53:27AM +0200, Richard Biener via Gcc-patches wrote: > On Wed, Jun 23, 2021 at 9:19 AM Hongtao Liu via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > Here's the patch I'm going to check in. > > > > The patch will regress pr91838.C with extra options: -march=cascadelake > > > > using T = unsigned char; // or ushort, or uint > > using V [[gnu::vector_size(8)]] = T; > > V f(V x) { return x >> 8 * sizeof(T); } > > > > Basically, the testcase is UB with logic right shift more than 8 bits > > I don't see any UB here, it's just x >> 8 but we indeed fail to constant > fold this. For scalars bit CCP does this, but we seem to lack a
For scalar T y = ...; y >> 8 is not UB because of integral promotion to int, but we do not perform such integral promotions for vector types, so arguably x >> 8 is UB. Jakub