public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug tree-optimization/103999] New: Vectorizer failed to reduce sum with conversion. @ 2022-01-13 1:25 crazylht at gmail dot com 2022-01-13 1:29 ` [Bug tree-optimization/103999] " crazylht at gmail dot com 2022-01-13 8:35 ` rguenth at gcc dot gnu.org 0 siblings, 2 replies; 3+ messages in thread From: crazylht at gmail dot com @ 2022-01-13 1:25 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103999 Bug ID: 103999 Summary: Vectorizer failed to reduce sum with conversion. Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: crazylht at gmail dot com Target Milestone: --- Vectorizer failed for sum_reduce_cd, but ok for sum_reduce/sum_reduce_cint float sum_reduce_cd (int n, float* array) { float ans = 0.0f, x; for (int i = 0; i != n; i++) { x = array[i]; ans += x + 1.0; } return ans; } float sum_reduce (int n, float* array) { float ans = 0.0f, x; for (int i = 0; i != n; i++) { x = array[i]; ans += x + 1.0f; } return ans; } float sum_reduce_cint (int n, float* array) { int ans = 0; float x; for (int i = 0; i != n; i++) { x = array[i]; ans += (int)(x + 1.0); } return ans; } https://godbolt.org/z/q3McP6d15 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/103999] Vectorizer failed to reduce sum with conversion. 2022-01-13 1:25 [Bug tree-optimization/103999] New: Vectorizer failed to reduce sum with conversion crazylht at gmail dot com @ 2022-01-13 1:29 ` crazylht at gmail dot com 2022-01-13 8:35 ` rguenth at gcc dot gnu.org 1 sibling, 0 replies; 3+ messages in thread From: crazylht at gmail dot com @ 2022-01-13 1:29 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103999 --- Comment #1 from Hongtao.liu <crazylht at gmail dot com> --- the difference between sum_reduce_cd and sum_reduce is one is 1.0 which is double and another is 1.0f which doesn't need any conversion and truncation. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/103999] Vectorizer failed to reduce sum with conversion. 2022-01-13 1:25 [Bug tree-optimization/103999] New: Vectorizer failed to reduce sum with conversion crazylht at gmail dot com 2022-01-13 1:29 ` [Bug tree-optimization/103999] " crazylht at gmail dot com @ 2022-01-13 8:35 ` rguenth at gcc dot gnu.org 1 sibling, 0 replies; 3+ messages in thread From: rguenth at gcc dot gnu.org @ 2022-01-13 8:35 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103999 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |53947 Keywords| |missed-optimization Ever confirmed|0 |1 Last reconfirmed| |2022-01-13 Status|UNCONFIRMED |NEW --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- t.c:4:23: note: reduction path: ans_15 _7 _9 _4 ans_18 t.c:4:23: note: reduction: unknown pattern We do handle integer sign conversions by "ignoring" them but with float truncations/extensions we have to be more careful. We start with ((double)(float)((double)(float)(array[0] + 1.) + array[1] + 1.) + array[2] + 1.) ... and would need to associate that in some way. Ideally we'd arrange for doing the reduction as 'double' and only truncate the final value getting us "only" extra precision. But that would require major surgery in reduction handling. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947 [Bug 53947] [meta-bug] vectorizer missed-optimizations ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-13 8:35 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-01-13 1:25 [Bug tree-optimization/103999] New: Vectorizer failed to reduce sum with conversion crazylht at gmail dot com 2022-01-13 1:29 ` [Bug tree-optimization/103999] " crazylht at gmail dot com 2022-01-13 8:35 ` rguenth 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).