Bug 101634 - Vectorize optimisations trigger floating point exception
Summary: Vectorize optimisations trigger floating point exception
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 11.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2021-07-27 07:52 UTC by William Bainbridge
Modified: 2021-07-27 14:25 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Code that reproduces the issue (1.37 KB, text/x-csrc)
2021-07-27 07:52 UTC, William Bainbridge
Details

Note You need to log in before you can comment on or make changes to this bug.
Description William Bainbridge 2021-07-27 07:52:33 UTC
Created attachment 51208 [details]
Code that reproduces the issue

I am using g++ 11.1.1 on OpenSUSE Tumbleweed 20210713.

When compiled with `g++ -O3 example.cpp` the code snippet triggers a floating point exception and the program exits through the `signalHandler` function. I believe this behaviour to be incorrect.

When compiled with `g++ -O3 -fno-tree-slp-vectorize example.cpp` (or any lower level of optimisation) the exception is not triggered and the program exits normally.

When compiled with any older version of `g++` with `O3` the exception is not triggered and the program exits normally.

The program can also be modified to read it's input values from a file (see commented section). This is shown to prove that the optimisation is not dependent on the values being available at compile time. Indeed, this is a snippet of a larger program in which the values are read in from a file.
Comment 1 Richard Biener 2021-07-27 11:10:50 UTC
I believe the issue has been fixed already and is a duplicate of PR100778.  There's an updated GCC 11 package pending in https://build.opensuse.org/project/show/openSUSE:Factory:Staging:A which you could verify against (or in devel:gcc which should even be published).

A locally built g++ from the GCC 11 branch doesn't reproduce the issue for me.

*** This bug has been marked as a duplicate of bug 100778 ***
Comment 2 William Bainbridge 2021-07-27 14:25:47 UTC
Thank you for looking into it. I have verified that gcc-11.2-RC-20210721 fixes the issue.