[Bug middle-end/114700] Front-end optimization generates wrong code with -ftrapv.

2024-04-11 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114700 --- Comment #9 from Richard Biener --- That that GCC doesn't promise that -ftrapv preserves all overflows and traps, it merely guarantees that all overflows that actually happen trap. So GCC is fine to contract some expressions where the overal

[Bug middle-end/114700] Front-end optimization generates wrong code with -ftrapv.

2024-04-11 Thread lin1.hu at intel dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114700 --- Comment #8 from lin1.hu at intel dot com --- (In reply to Andrew Pinski from comment #6) > Note `c - y - c` to become `-y` reduces the possible of an overflow and is > well defined for wrapping so this might be still on purpose as there wil

[Bug middle-end/114700] Front-end optimization generates wrong code with -ftrapv.

2024-04-11 Thread lin1.hu at intel dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114700 --- Comment #7 from lin1.hu at intel dot com --- (In reply to Andrew Pinski from comment #5) > From match.pd: > /* Match patterns that allow contracting a plus-minus pair > irrespective of overflow issues. */ > /* (A +- B) - A ->

[Bug middle-end/114700] Front-end optimization generates wrong code with -ftrapv.

2024-04-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114700 Andrew Pinski changed: What|Removed |Added See Also||https://gcc.gnu.org/bugzill

[Bug middle-end/114700] Front-end optimization generates wrong code with -ftrapv.

2024-04-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114700 --- Comment #5 from Andrew Pinski --- >From match.pd: /* Match patterns that allow contracting a plus-minus pair irrespective of overflow issues. */ /* (A +- B) - A -> +- B */ /* (A +- B) -+ B -> A */ /* A - (A +- B)

[Bug middle-end/114700] Front-end optimization generates wrong code with -ftrapv.

2024-04-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114700 --- Comment #4 from Andrew Pinski --- int z; void func(int a, int b, int c, int y){ z = c - y - c + a + y - b; }

[Bug middle-end/114700] Front-end optimization generates wrong code with -ftrapv.

2024-04-11 Thread lin1.hu at intel dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114700 --- Comment #3 from lin1.hu at intel dot com --- (In reply to lin1.hu from comment #2) > (In reply to Andrew Pinski from comment #1) > > Gcc's trapv is known not always to work correctly. > > > > Try -fsanitize=undefined instead. Thanks, it sol

[Bug middle-end/114700] Front-end optimization generates wrong code with -ftrapv.

2024-04-11 Thread lin1.hu at intel dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114700 --- Comment #2 from lin1.hu at intel dot com --- (In reply to Andrew Pinski from comment #1) > Gcc's trapv is known not always to work correctly. > > Try -fsanitize=undefined instead. Thanks, it solves the problem to some extent. But c is elimi

[Bug middle-end/114700] Front-end optimization generates wrong code with -ftrapv.

2024-04-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114700 --- Comment #1 from Andrew Pinski --- Gcc's trapv is known not always to work correctly. Try -fsanitize=undefined instead.