https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #8)
> I think the problem happens during combine.  Parts of the vector code
> related to:
>   V b = (V) { } >= o;
>   V c = b <= (V)(b >= (V) { 0, 0, 0, 0, 0, 0x90DF0BE3990AC871ULL });
> - in particular the scalar c[5] computation, i.e.
> unsigned long long b = 0 >= o ? -1ULL : 0ULL;
> unsigned long long c = b <= (b >= 0x90DF0BE3990AC871ULL ? -1ULL : 0ULL) ?
> -1ULL : 0ULL;
> evaluates to 0 rather than -1 that it should when o is 0.
> 
> This boils down to:
> __attribute__((noipa)) unsigned long long
> foo (unsigned char o)
> {
>   unsigned long long t1 = -(long long) (o == 0);
>   unsigned long long t2 = -(long long) (t1 > 10439075533421201520ULL);
>   unsigned long long t3 = -(long long) (t1 <= t2);
>   return t3;
> }
> 
> int
> main ()
> {
>   if (foo (0) != -1ULL)
>     __builtin_abort ();
>   return 0;
> }
> at -O2 or -Os, which was miscompiled starting with r12-303-g86403f4e6e5f7216
> and got fixed with r13-3530-g0e36a9c6915c713d30.
> No idea why this is marked as 11 regression though...
> 
> So, do we need to backport PR107172 change to 12 branch?

Yes.  Testing that now.

Reply via email to