public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug tree-optimization/105295] New: missed optimization with -ftrapv for conditional constants @ 2022-04-16 19:02 roland.illig at gmx dot de 2022-04-17 21:18 ` [Bug tree-optimization/105295] " pinskia at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: roland.illig at gmx dot de @ 2022-04-16 19:02 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105295 Bug ID: 105295 Summary: missed optimization with -ftrapv for conditional constants Product: gcc Version: 12.0 URL: https://godbolt.org/z/4rojo77a7 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: roland.illig at gmx dot de Target Milestone: --- ~~~c int sum_const(_Bool a, _Bool b) { return (a ? 1 : 0 ) + (b ? 1 : 0); } int sum_unknown(int a, int b) { return a + b; } ~~~ For both functions, GCC calls __addvsi3, even though in sum_const, it is easy to see that no overflow can ever happen since the sum is always in the range [0 ... 2]. Clang optimizes this code reasonably. ICC apparently does not care about -ftrapv at all. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/105295] missed optimization with -ftrapv for conditional constants 2022-04-16 19:02 [Bug tree-optimization/105295] New: missed optimization with -ftrapv for conditional constants roland.illig at gmx dot de @ 2022-04-17 21:18 ` pinskia at gcc dot gnu.org 2022-04-17 21:18 ` pinskia at gcc dot gnu.org 2022-04-17 21:19 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-04-17 21:18 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105295 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement URL|https://godbolt.org/z/4rojo | |77a7 | --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- https://godbolt.org/z/4rojo77a7 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/105295] missed optimization with -ftrapv for conditional constants 2022-04-16 19:02 [Bug tree-optimization/105295] New: missed optimization with -ftrapv for conditional constants roland.illig at gmx dot de 2022-04-17 21:18 ` [Bug tree-optimization/105295] " pinskia at gcc dot gnu.org @ 2022-04-17 21:18 ` pinskia at gcc dot gnu.org 2022-04-17 21:19 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-04-17 21:18 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105295 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Yes trapv is implemented during expansion (from gimple to RTL) and not really optimized. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/105295] missed optimization with -ftrapv for conditional constants 2022-04-16 19:02 [Bug tree-optimization/105295] New: missed optimization with -ftrapv for conditional constants roland.illig at gmx dot de 2022-04-17 21:18 ` [Bug tree-optimization/105295] " pinskia at gcc dot gnu.org 2022-04-17 21:18 ` pinskia at gcc dot gnu.org @ 2022-04-17 21:19 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-04-17 21:19 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105295 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |101521 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- PR 101521 records on how it should be implemented differently. Maybe for GCC 13, it will change. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101521 [Bug 101521] -ftrapv should become something like -fsanitize=undefined -fsanitize-undefined-trap-on-error ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-17 21:19 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-04-16 19:02 [Bug tree-optimization/105295] New: missed optimization with -ftrapv for conditional constants roland.illig at gmx dot de 2022-04-17 21:18 ` [Bug tree-optimization/105295] " pinskia at gcc dot gnu.org 2022-04-17 21:18 ` pinskia at gcc dot gnu.org 2022-04-17 21:19 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).