https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64153
Bug ID: 64153 Summary: [5.0 regression] r218205 miscompiles libgomp Product: gcc Version: 5.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: sch...@linux-m68k.org CC: mjambor at suse dot cz Blocks: 63551 Target: m68k-*-* Created attachment 34164 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34164&action=edit reduced testcase The attached testcase it reduced from libgomp/env.c. When compiled with -O2 it misoptimizes "if (task)" to 1, losing the call to gomp_new_icv. --- env.s.good +++ env.s.bad 2014-12-02 15:29:50.135924092 +0100 @@ -12,26 +12,18 @@ omp_set_num_threads: jsr __m68k_read_tp add.l gomp_tls_data@TLSIE(%a5),%a0 move.l (%a0),%a0 - tst.l %a0 - jeq .L7 move.l 8(%fp),%d0 - jle .L8 -.L4: + jle .L5 move.l %d0,(%a0) move.l -4(%fp),%a5 unlk %fp rts -.L8: +.L5: moveq #1,%d0 move.l %d0,(%a0) move.l -4(%fp),%a5 unlk %fp rts -.L7: - jsr gomp_new_icv - move.l 8(%fp),%d0 - jgt .L4 - jra .L8 .size omp_set_num_threads, .-omp_set_num_threads .align 2 .globl omp_set_dynamic @@ -43,17 +35,6 @@ omp_set_dynamic: jsr __m68k_read_tp add.l gomp_tls_data@TLSIE(%a5),%a0 move.l (%a0),%a0 - tst.l %a0 - jeq .L14 - tst.l 8(%fp) - sne %d0 - neg.b %d0 - move.b %d0,4(%a0) - move.l -4(%fp),%a5 - unlk %fp - rts -.L14: - jsr gomp_new_icv tst.l 8(%fp) sne %d0 neg.b %d0