From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 850103858D39; Wed, 8 Feb 2023 11:16:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 850103858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675855002; bh=pmRDehge6juO17bsv1BUUB59rZphZenrUQkY7efO6DA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=T/V+eYI13npv2JIXZVecjOZrglq+wIrtfzoQEadM5vdUap3rELSpNsYEYVCE1btkE e9rwbLunOfBjDNq82xf9yqKREBPepjT0RJ4PHYbDQdfMEzcqf6i502v/IQtL2K7eWe aI7wM4b7SpdnetDKPQvIgiAtROeoG6KYP2x3GFV4= From: "marxin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/108695] [13 Regression] Wrong code since r13-5215-gb1f30bf42d8d47 for dd_rescue package Date: Wed, 08 Feb 2023 11:16:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: lto, needs-reduction, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: marxin at gcc dot gnu.org X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108695 --- Comment #6 from Martin Li=C5=A1ka --- (In reply to Andrew Pinski from comment #5) > I am 99% sure there is aliasing violations in this code too: > #if _MSC_VER > #define GETU32(p) SWAP(*((u32 *)(p))) > #define PUTU32(ct, st) \ > { \ > *((u32 *)(ct)) =3D SWAP((st)); = \ > } Yes, I'm also suspecting this code and I can verify that using optimize("O0= ") for rijndaelEncrypt fixes the issue. The thing below is cast from 'const u8 *' and I thought it's valid to case to 'u32 *' and then access it. Can you explain to me how exactly the violat= ion happens? > #else /* _MSC_VER */ > # if __BYTE_ORDER =3D=3D __BIG_ENDIAN > #define GETU32(p) *((u32*)(p)) > #define PUTU32(ct, st) *((u32*)(ct)) =3D (st) > #else /* BIG_ENDIAN */ > #if 0 //def HAVE_LINUX_SWAB_H > #define GETU32(p) __swab32(*((u32*)(p))) > #define PUTU32(ct, st) *((u32*)(ct)) =3D __swab32((st)) > #else /* __GNUC__ */ > #include > #define GETU32(p) ntohl(*((u32*)(p))) > #define PUTU32(ct, st) *((u32*)(ct)) =3D htonl((st)) > #endif /* __GNUC__ */ > #endif /* BIG_ENDIAN */ > #endif /*_MSC_VER */ >=20 This part below is guarded with '#if 0'.. > #if 0 > #define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ > ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) > #define PUTU32(ct, st) \ > { \ > (ct)[0] =3D (u8)((st) >> 24); = \ > (ct)[1] =3D (u8)((st) >> 16); = \ > (ct)[2] =3D (u8)((st) >> 8); = \ > (ct)[3] =3D (u8)(st); = \ > } > #endif >=20 > A few other places too ...=