From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1BB473857C40; Wed, 5 Aug 2020 11:09:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BB473857C40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1596625783; bh=QBBJ4HyY93FS5TgvScgsDGjFd8xQ8X35mbooUlhtwmE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wbH405k0ZpXA+8kmqMG5SO/tM6EnKBDvle6lgcGaV+xvNjO2Vr6FctGuZTZxKOjPc BiVdC06NH8gzkSLmOD5QFQWJfFPXwPYxA1wev9r0ATTWslXAcKajnoAC1Ct5xmg4t/ 27zjSec3AsJOoFYtbQ4AR5K1zxQIPj6IeVhLwlzI= From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/96373] SVE miscompilation on vectorized division loop, leading to FP exception Date: Wed, 05 Aug 2020 11:09:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.2.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rsandifo at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Aug 2020 11:09:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96373 --- Comment #9 from rguenther at suse dot de --- On Wed, 5 Aug 2020, rsandifo at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96373 >=20 > --- Comment #8 from rsandifo at gcc dot gnu.org --- > (In reply to rguenther@suse.de from comment #7) > > On Wed, 5 Aug 2020, rsandifo at gcc dot gnu.org wrote: > >=20 > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96373 > > >=20 > > > --- Comment #6 from rsandifo at gcc dot gnu.org --- > > > FWIW, I think the reason I mentioned for skimping on this originally > > > was that we don't e.g. prevent if-conversion of: > > >=20 > > > void > > > foo (int *c, float *f) > > > { > > > for (int i =3D 0; i < 16; ++i) > > > f[i] =3D c[i] ? __builtin_sqrtf (f[i]) : f[i]; > > > } > > >=20 > > > for -O2 -ftree-vectorize -fno-math-errno. So it seemed like things > > > weren't very consistent. > >=20 > > I think that's a bug in if-conversion - gimple_could_trap_p only > > says that the call instruction itself doesn't trap, it doesn't > > say anything about something in the callee body. > When's that distinction useful in practice though? It seems odd > that an FP x / y is seen as potentially trapping, but a function > call that wraps (or might wrap) an FP x / y isn't. >=20 > > You should need -fno-trapping-math to get the above if-converted. > Is there an existing ECF flag that we can check? ECF_NOTHROW is > related but seems different enough not to be reliable. >=20 > And is trapping a =E2=80=9Cside effect=E2=80=9C for the purposes of: Yes, I think trapping would be a gimple_has_side_effects effect. No, I don't think NOTRHOW covers this. On GENERIC we have TREE_THIS_NOTRAP but it's not even specified for CALL_EXPR. > /* Nonzero if this is a call to a function whose return value depends=20= =20=20=20=20=20=20=20=20=20=20 > solely on its arguments, has no side effects, and does not read=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 > global memory. This corresponds to TREE_READONLY for function=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20 > decls. */ > #define ECF_CONST (1 << 0) >=20 > I.e. can a function still be const (on the basis that a given > argument always produces the same result) while still trapping > for some arguments? What about pure, where the trapping might > come from a memory dereference? How do we represent sNaNs with -fnon-call-exceptions? That is, y_1 =3D x_2 + 1.; may trap. Does foo (x_2); get transformed to tem_3 =3D x_2; foo (tem_3); and the SSA assignment now traps dependent on whether the call ABI requires pushing x_2 to a stack slot (which might trap)? sNaNs are odd anyway I guess. But yes, a pure function can still trap (and also throw). I think we don't have a good notion for trappingness of calls and I do expect inconsistencies here.=