This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/82677] Many projects (linux, coreutils, GMP, gcrypt, openSSL, etc) are misusing asm(divq/divl) etc, potentially resulting in faulty/unintended optimisations
- From: "infinity0 at pwned dot gg" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 23 Oct 2017 12:04:43 +0000
- Subject: [Bug rtl-optimization/82677] Many projects (linux, coreutils, GMP, gcrypt, openSSL, etc) are misusing asm(divq/divl) etc, potentially resulting in faulty/unintended optimisations
- Auto-submitted: auto-generated
- References: <bug-82677-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82677
--- Comment #5 from infinity0 at pwned dot gg ---
(In reply to Richard Biener from comment #4)
> [..]
> It's still safe to move the asm in
>
> int main() {
> ulong d = 0;
> for (ulong i = 0; i < 3; i++)
> for (ulong j = 0; j < 3; j++)
> {
> ulong r;
> __asm__("" : "=r"(d) : "rm"((ulong)0));
> udiv_qrnnd(q, r, 0, 0, (i << d));
> }
> }
>
> thus without the if ().
For the specific case of asm(div) I suppose it's safe because raising a DE is
pretty much similar to raising it several times in a loop, but it is correct to
assume that for all types of side effects?