https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66975
Bug ID: 66975 Summary: parloops to handle signed int reductions Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- With this ( https://gcc.gnu.org/ml/gcc-cvs/2015-07/msg00896.html ) fix we introduce xfails for signed int reductions: ... * gcc.dg/autopar/outer-4.c: Add xfail. * gcc.dg/autopar/outer-5.c: Same. * gcc.dg/autopar/outer-6.c: Same. * gcc.dg/autopar/reduc-2.c: Same. * gcc.dg/autopar/reduc-2char.c: Same. * gcc.dg/autopar/reduc-2short.c: Same. * gcc.dg/autopar/reduc-8.c: Same. ... The problem is that when parallelizing reductions in parloops, we change the order of evaluation, which can mean that we introduce an overflow, where there was none before. This only yields the same result if the overflow behaviour can be assumed to wrap. The fix adds this missing check. However, we can convert the signed reduction to an unsigned one, correctly parallelize it, and cast the result back to signed.