aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-parloops.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-01-14 16:56:44 +0100
committerMartin Liska <mliska@suse.cz>2022-01-17 22:12:04 +0100
commit5c69acb32329d49e58c26fa41ae74229a52b9106 (patch)
treeddb05f9d73afb6f998457d2ac4b720e3b3b60483 /gcc/tree-parloops.c
parent490e23032baaece71f2ec09fa1805064b150fbc2 (diff)
downloadgcc-5c69acb32329d49e58c26fa41ae74229a52b9106.zip
gcc-5c69acb32329d49e58c26fa41ae74229a52b9106.tar.gz
gcc-5c69acb32329d49e58c26fa41ae74229a52b9106.tar.bz2
Rename .c files to .cc files.
gcc/ada/ChangeLog: * adadecode.c: Moved to... * adadecode.cc: ...here. * affinity.c: Moved to... * affinity.cc: ...here. * argv-lynxos178-raven-cert.c: Moved to... * argv-lynxos178-raven-cert.cc: ...here. * argv.c: Moved to... * argv.cc: ...here. * aux-io.c: Moved to... * aux-io.cc: ...here. * cio.c: Moved to... * cio.cc: ...here. * cstreams.c: Moved to... * cstreams.cc: ...here. * env.c: Moved to... * env.cc: ...here. * exit.c: Moved to... * exit.cc: ...here. * expect.c: Moved to... * expect.cc: ...here. * final.c: Moved to... * final.cc: ...here. * gcc-interface/cuintp.c: Moved to... * gcc-interface/cuintp.cc: ...here. * gcc-interface/decl.c: Moved to... * gcc-interface/decl.cc: ...here. * gcc-interface/misc.c: Moved to... * gcc-interface/misc.cc: ...here. * gcc-interface/targtyps.c: Moved to... * gcc-interface/targtyps.cc: ...here. * gcc-interface/trans.c: Moved to... * gcc-interface/trans.cc: ...here. * gcc-interface/utils.c: Moved to... * gcc-interface/utils.cc: ...here. * gcc-interface/utils2.c: Moved to... * gcc-interface/utils2.cc: ...here. * init.c: Moved to... * init.cc: ...here. * initialize.c: Moved to... * initialize.cc: ...here. * libgnarl/thread.c: Moved to... * libgnarl/thread.cc: ...here. * link.c: Moved to... * link.cc: ...here. * locales.c: Moved to... * locales.cc: ...here. * mkdir.c: Moved to... * mkdir.cc: ...here. * raise.c: Moved to... * raise.cc: ...here. * rtfinal.c: Moved to... * rtfinal.cc: ...here. * rtinit.c: Moved to... * rtinit.cc: ...here. * seh_init.c: Moved to... * seh_init.cc: ...here. * sigtramp-armdroid.c: Moved to... * sigtramp-armdroid.cc: ...here. * sigtramp-ios.c: Moved to... * sigtramp-ios.cc: ...here. * sigtramp-qnx.c: Moved to... * sigtramp-qnx.cc: ...here. * sigtramp-vxworks.c: Moved to... * sigtramp-vxworks.cc: ...here. * socket.c: Moved to... * socket.cc: ...here. * tracebak.c: Moved to... * tracebak.cc: ...here. * version.c: Moved to... * version.cc: ...here. * vx_stack_info.c: Moved to... * vx_stack_info.cc: ...here. gcc/ChangeLog: * adjust-alignment.c: Moved to... * adjust-alignment.cc: ...here. * alias.c: Moved to... * alias.cc: ...here. * alloc-pool.c: Moved to... * alloc-pool.cc: ...here. * asan.c: Moved to... * asan.cc: ...here. * attribs.c: Moved to... * attribs.cc: ...here. * auto-inc-dec.c: Moved to... * auto-inc-dec.cc: ...here. * auto-profile.c: Moved to... * auto-profile.cc: ...here. * bb-reorder.c: Moved to... * bb-reorder.cc: ...here. * bitmap.c: Moved to... * bitmap.cc: ...here. * btfout.c: Moved to... * btfout.cc: ...here. * builtins.c: Moved to... * builtins.cc: ...here. * caller-save.c: Moved to... * caller-save.cc: ...here. * calls.c: Moved to... * calls.cc: ...here. * ccmp.c: Moved to... * ccmp.cc: ...here. * cfg.c: Moved to... * cfg.cc: ...here. * cfganal.c: Moved to... * cfganal.cc: ...here. * cfgbuild.c: Moved to... * cfgbuild.cc: ...here. * cfgcleanup.c: Moved to... * cfgcleanup.cc: ...here. * cfgexpand.c: Moved to... * cfgexpand.cc: ...here. * cfghooks.c: Moved to... * cfghooks.cc: ...here. * cfgloop.c: Moved to... * cfgloop.cc: ...here. * cfgloopanal.c: Moved to... * cfgloopanal.cc: ...here. * cfgloopmanip.c: Moved to... * cfgloopmanip.cc: ...here. * cfgrtl.c: Moved to... * cfgrtl.cc: ...here. * cgraph.c: Moved to... * cgraph.cc: ...here. * cgraphbuild.c: Moved to... * cgraphbuild.cc: ...here. * cgraphclones.c: Moved to... * cgraphclones.cc: ...here. * cgraphunit.c: Moved to... * cgraphunit.cc: ...here. * collect-utils.c: Moved to... * collect-utils.cc: ...here. * collect2-aix.c: Moved to... * collect2-aix.cc: ...here. * collect2.c: Moved to... * collect2.cc: ...here. * combine-stack-adj.c: Moved to... * combine-stack-adj.cc: ...here. * combine.c: Moved to... * combine.cc: ...here. * common/common-targhooks.c: Moved to... * common/common-targhooks.cc: ...here. * common/config/aarch64/aarch64-common.c: Moved to... * common/config/aarch64/aarch64-common.cc: ...here. * common/config/alpha/alpha-common.c: Moved to... * common/config/alpha/alpha-common.cc: ...here. * common/config/arc/arc-common.c: Moved to... * common/config/arc/arc-common.cc: ...here. * common/config/arm/arm-common.c: Moved to... * common/config/arm/arm-common.cc: ...here. * common/config/avr/avr-common.c: Moved to... * common/config/avr/avr-common.cc: ...here. * common/config/bfin/bfin-common.c: Moved to... * common/config/bfin/bfin-common.cc: ...here. * common/config/bpf/bpf-common.c: Moved to... * common/config/bpf/bpf-common.cc: ...here. * common/config/c6x/c6x-common.c: Moved to... * common/config/c6x/c6x-common.cc: ...here. * common/config/cr16/cr16-common.c: Moved to... * common/config/cr16/cr16-common.cc: ...here. * common/config/cris/cris-common.c: Moved to... * common/config/cris/cris-common.cc: ...here. * common/config/csky/csky-common.c: Moved to... * common/config/csky/csky-common.cc: ...here. * common/config/default-common.c: Moved to... * common/config/default-common.cc: ...here. * common/config/epiphany/epiphany-common.c: Moved to... * common/config/epiphany/epiphany-common.cc: ...here. * common/config/fr30/fr30-common.c: Moved to... * common/config/fr30/fr30-common.cc: ...here. * common/config/frv/frv-common.c: Moved to... * common/config/frv/frv-common.cc: ...here. * common/config/gcn/gcn-common.c: Moved to... * common/config/gcn/gcn-common.cc: ...here. * common/config/h8300/h8300-common.c: Moved to... * common/config/h8300/h8300-common.cc: ...here. * common/config/i386/i386-common.c: Moved to... * common/config/i386/i386-common.cc: ...here. * common/config/ia64/ia64-common.c: Moved to... * common/config/ia64/ia64-common.cc: ...here. * common/config/iq2000/iq2000-common.c: Moved to... * common/config/iq2000/iq2000-common.cc: ...here. * common/config/lm32/lm32-common.c: Moved to... * common/config/lm32/lm32-common.cc: ...here. * common/config/m32r/m32r-common.c: Moved to... * common/config/m32r/m32r-common.cc: ...here. * common/config/m68k/m68k-common.c: Moved to... * common/config/m68k/m68k-common.cc: ...here. * common/config/mcore/mcore-common.c: Moved to... * common/config/mcore/mcore-common.cc: ...here. * common/config/microblaze/microblaze-common.c: Moved to... * common/config/microblaze/microblaze-common.cc: ...here. * common/config/mips/mips-common.c: Moved to... * common/config/mips/mips-common.cc: ...here. * common/config/mmix/mmix-common.c: Moved to... * common/config/mmix/mmix-common.cc: ...here. * common/config/mn10300/mn10300-common.c: Moved to... * common/config/mn10300/mn10300-common.cc: ...here. * common/config/msp430/msp430-common.c: Moved to... * common/config/msp430/msp430-common.cc: ...here. * common/config/nds32/nds32-common.c: Moved to... * common/config/nds32/nds32-common.cc: ...here. * common/config/nios2/nios2-common.c: Moved to... * common/config/nios2/nios2-common.cc: ...here. * common/config/nvptx/nvptx-common.c: Moved to... * common/config/nvptx/nvptx-common.cc: ...here. * common/config/or1k/or1k-common.c: Moved to... * common/config/or1k/or1k-common.cc: ...here. * common/config/pa/pa-common.c: Moved to... * common/config/pa/pa-common.cc: ...here. * common/config/pdp11/pdp11-common.c: Moved to... * common/config/pdp11/pdp11-common.cc: ...here. * common/config/pru/pru-common.c: Moved to... * common/config/pru/pru-common.cc: ...here. * common/config/riscv/riscv-common.c: Moved to... * common/config/riscv/riscv-common.cc: ...here. * common/config/rs6000/rs6000-common.c: Moved to... * common/config/rs6000/rs6000-common.cc: ...here. * common/config/rx/rx-common.c: Moved to... * common/config/rx/rx-common.cc: ...here. * common/config/s390/s390-common.c: Moved to... * common/config/s390/s390-common.cc: ...here. * common/config/sh/sh-common.c: Moved to... * common/config/sh/sh-common.cc: ...here. * common/config/sparc/sparc-common.c: Moved to... * common/config/sparc/sparc-common.cc: ...here. * common/config/tilegx/tilegx-common.c: Moved to... * common/config/tilegx/tilegx-common.cc: ...here. * common/config/tilepro/tilepro-common.c: Moved to... * common/config/tilepro/tilepro-common.cc: ...here. * common/config/v850/v850-common.c: Moved to... * common/config/v850/v850-common.cc: ...here. * common/config/vax/vax-common.c: Moved to... * common/config/vax/vax-common.cc: ...here. * common/config/visium/visium-common.c: Moved to... * common/config/visium/visium-common.cc: ...here. * common/config/xstormy16/xstormy16-common.c: Moved to... * common/config/xstormy16/xstormy16-common.cc: ...here. * common/config/xtensa/xtensa-common.c: Moved to... * common/config/xtensa/xtensa-common.cc: ...here. * compare-elim.c: Moved to... * compare-elim.cc: ...here. * config/aarch64/aarch64-bti-insert.c: Moved to... * config/aarch64/aarch64-bti-insert.cc: ...here. * config/aarch64/aarch64-builtins.c: Moved to... * config/aarch64/aarch64-builtins.cc: ...here. * config/aarch64/aarch64-c.c: Moved to... * config/aarch64/aarch64-c.cc: ...here. * config/aarch64/aarch64-d.c: Moved to... * config/aarch64/aarch64-d.cc: ...here. * config/aarch64/aarch64.c: Moved to... * config/aarch64/aarch64.cc: ...here. * config/aarch64/cortex-a57-fma-steering.c: Moved to... * config/aarch64/cortex-a57-fma-steering.cc: ...here. * config/aarch64/driver-aarch64.c: Moved to... * config/aarch64/driver-aarch64.cc: ...here. * config/aarch64/falkor-tag-collision-avoidance.c: Moved to... * config/aarch64/falkor-tag-collision-avoidance.cc: ...here. * config/aarch64/host-aarch64-darwin.c: Moved to... * config/aarch64/host-aarch64-darwin.cc: ...here. * config/alpha/alpha.c: Moved to... * config/alpha/alpha.cc: ...here. * config/alpha/driver-alpha.c: Moved to... * config/alpha/driver-alpha.cc: ...here. * config/arc/arc-c.c: Moved to... * config/arc/arc-c.cc: ...here. * config/arc/arc.c: Moved to... * config/arc/arc.cc: ...here. * config/arc/driver-arc.c: Moved to... * config/arc/driver-arc.cc: ...here. * config/arm/aarch-common.c: Moved to... * config/arm/aarch-common.cc: ...here. * config/arm/arm-builtins.c: Moved to... * config/arm/arm-builtins.cc: ...here. * config/arm/arm-c.c: Moved to... * config/arm/arm-c.cc: ...here. * config/arm/arm-d.c: Moved to... * config/arm/arm-d.cc: ...here. * config/arm/arm.c: Moved to... * config/arm/arm.cc: ...here. * config/arm/driver-arm.c: Moved to... * config/arm/driver-arm.cc: ...here. * config/avr/avr-c.c: Moved to... * config/avr/avr-c.cc: ...here. * config/avr/avr-devices.c: Moved to... * config/avr/avr-devices.cc: ...here. * config/avr/avr-log.c: Moved to... * config/avr/avr-log.cc: ...here. * config/avr/avr.c: Moved to... * config/avr/avr.cc: ...here. * config/avr/driver-avr.c: Moved to... * config/avr/driver-avr.cc: ...here. * config/avr/gen-avr-mmcu-specs.c: Moved to... * config/avr/gen-avr-mmcu-specs.cc: ...here. * config/avr/gen-avr-mmcu-texi.c: Moved to... * config/avr/gen-avr-mmcu-texi.cc: ...here. * config/bfin/bfin.c: Moved to... * config/bfin/bfin.cc: ...here. * config/bpf/bpf.c: Moved to... * config/bpf/bpf.cc: ...here. * config/bpf/coreout.c: Moved to... * config/bpf/coreout.cc: ...here. * config/c6x/c6x.c: Moved to... * config/c6x/c6x.cc: ...here. * config/cr16/cr16.c: Moved to... * config/cr16/cr16.cc: ...here. * config/cris/cris.c: Moved to... * config/cris/cris.cc: ...here. * config/csky/csky.c: Moved to... * config/csky/csky.cc: ...here. * config/darwin-c.c: Moved to... * config/darwin-c.cc: ...here. * config/darwin-d.c: Moved to... * config/darwin-d.cc: ...here. * config/darwin-driver.c: Moved to... * config/darwin-driver.cc: ...here. * config/darwin-f.c: Moved to... * config/darwin-f.cc: ...here. * config/darwin.c: Moved to... * config/darwin.cc: ...here. * config/default-c.c: Moved to... * config/default-c.cc: ...here. * config/default-d.c: Moved to... * config/default-d.cc: ...here. * config/dragonfly-d.c: Moved to... * config/dragonfly-d.cc: ...here. * config/epiphany/epiphany.c: Moved to... * config/epiphany/epiphany.cc: ...here. * config/epiphany/mode-switch-use.c: Moved to... * config/epiphany/mode-switch-use.cc: ...here. * config/epiphany/resolve-sw-modes.c: Moved to... * config/epiphany/resolve-sw-modes.cc: ...here. * config/fr30/fr30.c: Moved to... * config/fr30/fr30.cc: ...here. * config/freebsd-d.c: Moved to... * config/freebsd-d.cc: ...here. * config/frv/frv.c: Moved to... * config/frv/frv.cc: ...here. * config/ft32/ft32.c: Moved to... * config/ft32/ft32.cc: ...here. * config/gcn/driver-gcn.c: Moved to... * config/gcn/driver-gcn.cc: ...here. * config/gcn/gcn-run.c: Moved to... * config/gcn/gcn-run.cc: ...here. * config/gcn/gcn-tree.c: Moved to... * config/gcn/gcn-tree.cc: ...here. * config/gcn/gcn.c: Moved to... * config/gcn/gcn.cc: ...here. * config/gcn/mkoffload.c: Moved to... * config/gcn/mkoffload.cc: ...here. * config/glibc-c.c: Moved to... * config/glibc-c.cc: ...here. * config/glibc-d.c: Moved to... * config/glibc-d.cc: ...here. * config/h8300/h8300.c: Moved to... * config/h8300/h8300.cc: ...here. * config/host-darwin.c: Moved to... * config/host-darwin.cc: ...here. * config/host-hpux.c: Moved to... * config/host-hpux.cc: ...here. * config/host-linux.c: Moved to... * config/host-linux.cc: ...here. * config/host-netbsd.c: Moved to... * config/host-netbsd.cc: ...here. * config/host-openbsd.c: Moved to... * config/host-openbsd.cc: ...here. * config/host-solaris.c: Moved to... * config/host-solaris.cc: ...here. * config/i386/djgpp.c: Moved to... * config/i386/djgpp.cc: ...here. * config/i386/driver-i386.c: Moved to... * config/i386/driver-i386.cc: ...here. * config/i386/driver-mingw32.c: Moved to... * config/i386/driver-mingw32.cc: ...here. * config/i386/gnu-property.c: Moved to... * config/i386/gnu-property.cc: ...here. * config/i386/host-cygwin.c: Moved to... * config/i386/host-cygwin.cc: ...here. * config/i386/host-i386-darwin.c: Moved to... * config/i386/host-i386-darwin.cc: ...here. * config/i386/host-mingw32.c: Moved to... * config/i386/host-mingw32.cc: ...here. * config/i386/i386-builtins.c: Moved to... * config/i386/i386-builtins.cc: ...here. * config/i386/i386-c.c: Moved to... * config/i386/i386-c.cc: ...here. * config/i386/i386-d.c: Moved to... * config/i386/i386-d.cc: ...here. * config/i386/i386-expand.c: Moved to... * config/i386/i386-expand.cc: ...here. * config/i386/i386-features.c: Moved to... * config/i386/i386-features.cc: ...here. * config/i386/i386-options.c: Moved to... * config/i386/i386-options.cc: ...here. * config/i386/i386.c: Moved to... * config/i386/i386.cc: ...here. * config/i386/intelmic-mkoffload.c: Moved to... * config/i386/intelmic-mkoffload.cc: ...here. * config/i386/msformat-c.c: Moved to... * config/i386/msformat-c.cc: ...here. * config/i386/winnt-cxx.c: Moved to... * config/i386/winnt-cxx.cc: ...here. * config/i386/winnt-d.c: Moved to... * config/i386/winnt-d.cc: ...here. * config/i386/winnt-stubs.c: Moved to... * config/i386/winnt-stubs.cc: ...here. * config/i386/winnt.c: Moved to... * config/i386/winnt.cc: ...here. * config/i386/x86-tune-sched-atom.c: Moved to... * config/i386/x86-tune-sched-atom.cc: ...here. * config/i386/x86-tune-sched-bd.c: Moved to... * config/i386/x86-tune-sched-bd.cc: ...here. * config/i386/x86-tune-sched-core.c: Moved to... * config/i386/x86-tune-sched-core.cc: ...here. * config/i386/x86-tune-sched.c: Moved to... * config/i386/x86-tune-sched.cc: ...here. * config/ia64/ia64-c.c: Moved to... * config/ia64/ia64-c.cc: ...here. * config/ia64/ia64.c: Moved to... * config/ia64/ia64.cc: ...here. * config/iq2000/iq2000.c: Moved to... * config/iq2000/iq2000.cc: ...here. * config/linux.c: Moved to... * config/linux.cc: ...here. * config/lm32/lm32.c: Moved to... * config/lm32/lm32.cc: ...here. * config/m32c/m32c-pragma.c: Moved to... * config/m32c/m32c-pragma.cc: ...here. * config/m32c/m32c.c: Moved to... * config/m32c/m32c.cc: ...here. * config/m32r/m32r.c: Moved to... * config/m32r/m32r.cc: ...here. * config/m68k/m68k.c: Moved to... * config/m68k/m68k.cc: ...here. * config/mcore/mcore.c: Moved to... * config/mcore/mcore.cc: ...here. * config/microblaze/microblaze-c.c: Moved to... * config/microblaze/microblaze-c.cc: ...here. * config/microblaze/microblaze.c: Moved to... * config/microblaze/microblaze.cc: ...here. * config/mips/driver-native.c: Moved to... * config/mips/driver-native.cc: ...here. * config/mips/frame-header-opt.c: Moved to... * config/mips/frame-header-opt.cc: ...here. * config/mips/mips-d.c: Moved to... * config/mips/mips-d.cc: ...here. * config/mips/mips.c: Moved to... * config/mips/mips.cc: ...here. * config/mmix/mmix.c: Moved to... * config/mmix/mmix.cc: ...here. * config/mn10300/mn10300.c: Moved to... * config/mn10300/mn10300.cc: ...here. * config/moxie/moxie.c: Moved to... * config/moxie/moxie.cc: ...here. * config/msp430/driver-msp430.c: Moved to... * config/msp430/driver-msp430.cc: ...here. * config/msp430/msp430-c.c: Moved to... * config/msp430/msp430-c.cc: ...here. * config/msp430/msp430-devices.c: Moved to... * config/msp430/msp430-devices.cc: ...here. * config/msp430/msp430.c: Moved to... * config/msp430/msp430.cc: ...here. * config/nds32/nds32-cost.c: Moved to... * config/nds32/nds32-cost.cc: ...here. * config/nds32/nds32-fp-as-gp.c: Moved to... * config/nds32/nds32-fp-as-gp.cc: ...here. * config/nds32/nds32-intrinsic.c: Moved to... * config/nds32/nds32-intrinsic.cc: ...here. * config/nds32/nds32-isr.c: Moved to... * config/nds32/nds32-isr.cc: ...here. * config/nds32/nds32-md-auxiliary.c: Moved to... * config/nds32/nds32-md-auxiliary.cc: ...here. * config/nds32/nds32-memory-manipulation.c: Moved to... * config/nds32/nds32-memory-manipulation.cc: ...here. * config/nds32/nds32-pipelines-auxiliary.c: Moved to... * config/nds32/nds32-pipelines-auxiliary.cc: ...here. * config/nds32/nds32-predicates.c: Moved to... * config/nds32/nds32-predicates.cc: ...here. * config/nds32/nds32-relax-opt.c: Moved to... * config/nds32/nds32-relax-opt.cc: ...here. * config/nds32/nds32-utils.c: Moved to... * config/nds32/nds32-utils.cc: ...here. * config/nds32/nds32.c: Moved to... * config/nds32/nds32.cc: ...here. * config/netbsd-d.c: Moved to... * config/netbsd-d.cc: ...here. * config/netbsd.c: Moved to... * config/netbsd.cc: ...here. * config/nios2/nios2.c: Moved to... * config/nios2/nios2.cc: ...here. * config/nvptx/mkoffload.c: Moved to... * config/nvptx/mkoffload.cc: ...here. * config/nvptx/nvptx-c.c: Moved to... * config/nvptx/nvptx-c.cc: ...here. * config/nvptx/nvptx.c: Moved to... * config/nvptx/nvptx.cc: ...here. * config/openbsd-d.c: Moved to... * config/openbsd-d.cc: ...here. * config/or1k/or1k.c: Moved to... * config/or1k/or1k.cc: ...here. * config/pa/pa-d.c: Moved to... * config/pa/pa-d.cc: ...here. * config/pa/pa.c: Moved to... * config/pa/pa.cc: ...here. * config/pdp11/pdp11.c: Moved to... * config/pdp11/pdp11.cc: ...here. * config/pru/pru-passes.c: Moved to... * config/pru/pru-passes.cc: ...here. * config/pru/pru-pragma.c: Moved to... * config/pru/pru-pragma.cc: ...here. * config/pru/pru.c: Moved to... * config/pru/pru.cc: ...here. * config/riscv/riscv-builtins.c: Moved to... * config/riscv/riscv-builtins.cc: ...here. * config/riscv/riscv-c.c: Moved to... * config/riscv/riscv-c.cc: ...here. * config/riscv/riscv-d.c: Moved to... * config/riscv/riscv-d.cc: ...here. * config/riscv/riscv-shorten-memrefs.c: Moved to... * config/riscv/riscv-shorten-memrefs.cc: ...here. * config/riscv/riscv-sr.c: Moved to... * config/riscv/riscv-sr.cc: ...here. * config/riscv/riscv.c: Moved to... * config/riscv/riscv.cc: ...here. * config/rl78/rl78-c.c: Moved to... * config/rl78/rl78-c.cc: ...here. * config/rl78/rl78.c: Moved to... * config/rl78/rl78.cc: ...here. * config/rs6000/driver-rs6000.c: Moved to... * config/rs6000/driver-rs6000.cc: ...here. * config/rs6000/host-darwin.c: Moved to... * config/rs6000/host-darwin.cc: ...here. * config/rs6000/host-ppc64-darwin.c: Moved to... * config/rs6000/host-ppc64-darwin.cc: ...here. * config/rs6000/rbtree.c: Moved to... * config/rs6000/rbtree.cc: ...here. * config/rs6000/rs6000-c.c: Moved to... * config/rs6000/rs6000-c.cc: ...here. * config/rs6000/rs6000-call.c: Moved to... * config/rs6000/rs6000-call.cc: ...here. * config/rs6000/rs6000-d.c: Moved to... * config/rs6000/rs6000-d.cc: ...here. * config/rs6000/rs6000-gen-builtins.c: Moved to... * config/rs6000/rs6000-gen-builtins.cc: ...here. * config/rs6000/rs6000-linux.c: Moved to... * config/rs6000/rs6000-linux.cc: ...here. * config/rs6000/rs6000-logue.c: Moved to... * config/rs6000/rs6000-logue.cc: ...here. * config/rs6000/rs6000-p8swap.c: Moved to... * config/rs6000/rs6000-p8swap.cc: ...here. * config/rs6000/rs6000-pcrel-opt.c: Moved to... * config/rs6000/rs6000-pcrel-opt.cc: ...here. * config/rs6000/rs6000-string.c: Moved to... * config/rs6000/rs6000-string.cc: ...here. * config/rs6000/rs6000.c: Moved to... * config/rs6000/rs6000.cc: ...here. * config/rx/rx.c: Moved to... * config/rx/rx.cc: ...here. * config/s390/driver-native.c: Moved to... * config/s390/driver-native.cc: ...here. * config/s390/s390-c.c: Moved to... * config/s390/s390-c.cc: ...here. * config/s390/s390-d.c: Moved to... * config/s390/s390-d.cc: ...here. * config/s390/s390.c: Moved to... * config/s390/s390.cc: ...here. * config/sh/divtab-sh4-300.c: Moved to... * config/sh/divtab-sh4-300.cc: ...here. * config/sh/divtab-sh4.c: Moved to... * config/sh/divtab-sh4.cc: ...here. * config/sh/divtab.c: Moved to... * config/sh/divtab.cc: ...here. * config/sh/sh-c.c: Moved to... * config/sh/sh-c.cc: ...here. * config/sh/sh.c: Moved to... * config/sh/sh.cc: ...here. * config/sol2-c.c: Moved to... * config/sol2-c.cc: ...here. * config/sol2-cxx.c: Moved to... * config/sol2-cxx.cc: ...here. * config/sol2-d.c: Moved to... * config/sol2-d.cc: ...here. * config/sol2-stubs.c: Moved to... * config/sol2-stubs.cc: ...here. * config/sol2.c: Moved to... * config/sol2.cc: ...here. * config/sparc/driver-sparc.c: Moved to... * config/sparc/driver-sparc.cc: ...here. * config/sparc/sparc-c.c: Moved to... * config/sparc/sparc-c.cc: ...here. * config/sparc/sparc-d.c: Moved to... * config/sparc/sparc-d.cc: ...here. * config/sparc/sparc.c: Moved to... * config/sparc/sparc.cc: ...here. * config/stormy16/stormy16.c: Moved to... * config/stormy16/stormy16.cc: ...here. * config/tilegx/mul-tables.c: Moved to... * config/tilegx/mul-tables.cc: ...here. * config/tilegx/tilegx-c.c: Moved to... * config/tilegx/tilegx-c.cc: ...here. * config/tilegx/tilegx.c: Moved to... * config/tilegx/tilegx.cc: ...here. * config/tilepro/mul-tables.c: Moved to... * config/tilepro/mul-tables.cc: ...here. * config/tilepro/tilepro-c.c: Moved to... * config/tilepro/tilepro-c.cc: ...here. * config/tilepro/tilepro.c: Moved to... * config/tilepro/tilepro.cc: ...here. * config/v850/v850-c.c: Moved to... * config/v850/v850-c.cc: ...here. * config/v850/v850.c: Moved to... * config/v850/v850.cc: ...here. * config/vax/vax.c: Moved to... * config/vax/vax.cc: ...here. * config/visium/visium.c: Moved to... * config/visium/visium.cc: ...here. * config/vms/vms-c.c: Moved to... * config/vms/vms-c.cc: ...here. * config/vms/vms-f.c: Moved to... * config/vms/vms-f.cc: ...here. * config/vms/vms.c: Moved to... * config/vms/vms.cc: ...here. * config/vxworks-c.c: Moved to... * config/vxworks-c.cc: ...here. * config/vxworks.c: Moved to... * config/vxworks.cc: ...here. * config/winnt-c.c: Moved to... * config/winnt-c.cc: ...here. * config/xtensa/xtensa.c: Moved to... * config/xtensa/xtensa.cc: ...here. * context.c: Moved to... * context.cc: ...here. * convert.c: Moved to... * convert.cc: ...here. * coverage.c: Moved to... * coverage.cc: ...here. * cppbuiltin.c: Moved to... * cppbuiltin.cc: ...here. * cppdefault.c: Moved to... * cppdefault.cc: ...here. * cprop.c: Moved to... * cprop.cc: ...here. * cse.c: Moved to... * cse.cc: ...here. * cselib.c: Moved to... * cselib.cc: ...here. * ctfc.c: Moved to... * ctfc.cc: ...here. * ctfout.c: Moved to... * ctfout.cc: ...here. * data-streamer-in.c: Moved to... * data-streamer-in.cc: ...here. * data-streamer-out.c: Moved to... * data-streamer-out.cc: ...here. * data-streamer.c: Moved to... * data-streamer.cc: ...here. * dbgcnt.c: Moved to... * dbgcnt.cc: ...here. * dbxout.c: Moved to... * dbxout.cc: ...here. * dce.c: Moved to... * dce.cc: ...here. * ddg.c: Moved to... * ddg.cc: ...here. * debug.c: Moved to... * debug.cc: ...here. * df-core.c: Moved to... * df-core.cc: ...here. * df-problems.c: Moved to... * df-problems.cc: ...here. * df-scan.c: Moved to... * df-scan.cc: ...here. * dfp.c: Moved to... * dfp.cc: ...here. * diagnostic-color.c: Moved to... * diagnostic-color.cc: ...here. * diagnostic-show-locus.c: Moved to... * diagnostic-show-locus.cc: ...here. * diagnostic-spec.c: Moved to... * diagnostic-spec.cc: ...here. * diagnostic.c: Moved to... * diagnostic.cc: ...here. * dojump.c: Moved to... * dojump.cc: ...here. * dominance.c: Moved to... * dominance.cc: ...here. * domwalk.c: Moved to... * domwalk.cc: ...here. * double-int.c: Moved to... * double-int.cc: ...here. * dse.c: Moved to... * dse.cc: ...here. * dumpfile.c: Moved to... * dumpfile.cc: ...here. * dwarf2asm.c: Moved to... * dwarf2asm.cc: ...here. * dwarf2cfi.c: Moved to... * dwarf2cfi.cc: ...here. * dwarf2ctf.c: Moved to... * dwarf2ctf.cc: ...here. * dwarf2out.c: Moved to... * dwarf2out.cc: ...here. * early-remat.c: Moved to... * early-remat.cc: ...here. * edit-context.c: Moved to... * edit-context.cc: ...here. * emit-rtl.c: Moved to... * emit-rtl.cc: ...here. * errors.c: Moved to... * errors.cc: ...here. * et-forest.c: Moved to... * et-forest.cc: ...here. * except.c: Moved to... * except.cc: ...here. * explow.c: Moved to... * explow.cc: ...here. * expmed.c: Moved to... * expmed.cc: ...here. * expr.c: Moved to... * expr.cc: ...here. * fibonacci_heap.c: Moved to... * fibonacci_heap.cc: ...here. * file-find.c: Moved to... * file-find.cc: ...here. * file-prefix-map.c: Moved to... * file-prefix-map.cc: ...here. * final.c: Moved to... * final.cc: ...here. * fixed-value.c: Moved to... * fixed-value.cc: ...here. * fold-const-call.c: Moved to... * fold-const-call.cc: ...here. * fold-const.c: Moved to... * fold-const.cc: ...here. * fp-test.c: Moved to... * fp-test.cc: ...here. * function-tests.c: Moved to... * function-tests.cc: ...here. * function.c: Moved to... * function.cc: ...here. * fwprop.c: Moved to... * fwprop.cc: ...here. * gcc-ar.c: Moved to... * gcc-ar.cc: ...here. * gcc-main.c: Moved to... * gcc-main.cc: ...here. * gcc-rich-location.c: Moved to... * gcc-rich-location.cc: ...here. * gcc.c: Moved to... * gcc.cc: ...here. * gcov-dump.c: Moved to... * gcov-dump.cc: ...here. * gcov-io.c: Moved to... * gcov-io.cc: ...here. * gcov-tool.c: Moved to... * gcov-tool.cc: ...here. * gcov.c: Moved to... * gcov.cc: ...here. * gcse-common.c: Moved to... * gcse-common.cc: ...here. * gcse.c: Moved to... * gcse.cc: ...here. * genattr-common.c: Moved to... * genattr-common.cc: ...here. * genattr.c: Moved to... * genattr.cc: ...here. * genattrtab.c: Moved to... * genattrtab.cc: ...here. * genautomata.c: Moved to... * genautomata.cc: ...here. * gencfn-macros.c: Moved to... * gencfn-macros.cc: ...here. * gencheck.c: Moved to... * gencheck.cc: ...here. * genchecksum.c: Moved to... * genchecksum.cc: ...here. * gencodes.c: Moved to... * gencodes.cc: ...here. * genconditions.c: Moved to... * genconditions.cc: ...here. * genconfig.c: Moved to... * genconfig.cc: ...here. * genconstants.c: Moved to... * genconstants.cc: ...here. * genemit.c: Moved to... * genemit.cc: ...here. * genenums.c: Moved to... * genenums.cc: ...here. * generic-match-head.c: Moved to... * generic-match-head.cc: ...here. * genextract.c: Moved to... * genextract.cc: ...here. * genflags.c: Moved to... * genflags.cc: ...here. * gengenrtl.c: Moved to... * gengenrtl.cc: ...here. * gengtype-parse.c: Moved to... * gengtype-parse.cc: ...here. * gengtype-state.c: Moved to... * gengtype-state.cc: ...here. * gengtype.c: Moved to... * gengtype.cc: ...here. * genhooks.c: Moved to... * genhooks.cc: ...here. * genmatch.c: Moved to... * genmatch.cc: ...here. * genmddeps.c: Moved to... * genmddeps.cc: ...here. * genmddump.c: Moved to... * genmddump.cc: ...here. * genmodes.c: Moved to... * genmodes.cc: ...here. * genopinit.c: Moved to... * genopinit.cc: ...here. * genoutput.c: Moved to... * genoutput.cc: ...here. * genpeep.c: Moved to... * genpeep.cc: ...here. * genpreds.c: Moved to... * genpreds.cc: ...here. * genrecog.c: Moved to... * genrecog.cc: ...here. * gensupport.c: Moved to... * gensupport.cc: ...here. * gentarget-def.c: Moved to... * gentarget-def.cc: ...here. * genversion.c: Moved to... * genversion.cc: ...here. * ggc-common.c: Moved to... * ggc-common.cc: ...here. * ggc-none.c: Moved to... * ggc-none.cc: ...here. * ggc-page.c: Moved to... * ggc-page.cc: ...here. * ggc-tests.c: Moved to... * ggc-tests.cc: ...here. * gimple-builder.c: Moved to... * gimple-builder.cc: ...here. * gimple-expr.c: Moved to... * gimple-expr.cc: ...here. * gimple-fold.c: Moved to... * gimple-fold.cc: ...here. * gimple-iterator.c: Moved to... * gimple-iterator.cc: ...here. * gimple-laddress.c: Moved to... * gimple-laddress.cc: ...here. * gimple-loop-jam.c: Moved to... * gimple-loop-jam.cc: ...here. * gimple-low.c: Moved to... * gimple-low.cc: ...here. * gimple-match-head.c: Moved to... * gimple-match-head.cc: ...here. * gimple-pretty-print.c: Moved to... * gimple-pretty-print.cc: ...here. * gimple-ssa-backprop.c: Moved to... * gimple-ssa-backprop.cc: ...here. * gimple-ssa-evrp-analyze.c: Moved to... * gimple-ssa-evrp-analyze.cc: ...here. * gimple-ssa-evrp.c: Moved to... * gimple-ssa-evrp.cc: ...here. * gimple-ssa-isolate-paths.c: Moved to... * gimple-ssa-isolate-paths.cc: ...here. * gimple-ssa-nonnull-compare.c: Moved to... * gimple-ssa-nonnull-compare.cc: ...here. * gimple-ssa-split-paths.c: Moved to... * gimple-ssa-split-paths.cc: ...here. * gimple-ssa-sprintf.c: Moved to... * gimple-ssa-sprintf.cc: ...here. * gimple-ssa-store-merging.c: Moved to... * gimple-ssa-store-merging.cc: ...here. * gimple-ssa-strength-reduction.c: Moved to... * gimple-ssa-strength-reduction.cc: ...here. * gimple-ssa-warn-alloca.c: Moved to... * gimple-ssa-warn-alloca.cc: ...here. * gimple-ssa-warn-restrict.c: Moved to... * gimple-ssa-warn-restrict.cc: ...here. * gimple-streamer-in.c: Moved to... * gimple-streamer-in.cc: ...here. * gimple-streamer-out.c: Moved to... * gimple-streamer-out.cc: ...here. * gimple-walk.c: Moved to... * gimple-walk.cc: ...here. * gimple-warn-recursion.c: Moved to... * gimple-warn-recursion.cc: ...here. * gimple.c: Moved to... * gimple.cc: ...here. * gimplify-me.c: Moved to... * gimplify-me.cc: ...here. * gimplify.c: Moved to... * gimplify.cc: ...here. * godump.c: Moved to... * godump.cc: ...here. * graph.c: Moved to... * graph.cc: ...here. * graphds.c: Moved to... * graphds.cc: ...here. * graphite-dependences.c: Moved to... * graphite-dependences.cc: ...here. * graphite-isl-ast-to-gimple.c: Moved to... * graphite-isl-ast-to-gimple.cc: ...here. * graphite-optimize-isl.c: Moved to... * graphite-optimize-isl.cc: ...here. * graphite-poly.c: Moved to... * graphite-poly.cc: ...here. * graphite-scop-detection.c: Moved to... * graphite-scop-detection.cc: ...here. * graphite-sese-to-poly.c: Moved to... * graphite-sese-to-poly.cc: ...here. * graphite.c: Moved to... * graphite.cc: ...here. * haifa-sched.c: Moved to... * haifa-sched.cc: ...here. * hash-map-tests.c: Moved to... * hash-map-tests.cc: ...here. * hash-set-tests.c: Moved to... * hash-set-tests.cc: ...here. * hash-table.c: Moved to... * hash-table.cc: ...here. * hooks.c: Moved to... * hooks.cc: ...here. * host-default.c: Moved to... * host-default.cc: ...here. * hw-doloop.c: Moved to... * hw-doloop.cc: ...here. * hwint.c: Moved to... * hwint.cc: ...here. * ifcvt.c: Moved to... * ifcvt.cc: ...here. * inchash.c: Moved to... * inchash.cc: ...here. * incpath.c: Moved to... * incpath.cc: ...here. * init-regs.c: Moved to... * init-regs.cc: ...here. * input.c: Moved to... * input.cc: ...here. * internal-fn.c: Moved to... * internal-fn.cc: ...here. * intl.c: Moved to... * intl.cc: ...here. * ipa-comdats.c: Moved to... * ipa-comdats.cc: ...here. * ipa-cp.c: Moved to... * ipa-cp.cc: ...here. * ipa-devirt.c: Moved to... * ipa-devirt.cc: ...here. * ipa-fnsummary.c: Moved to... * ipa-fnsummary.cc: ...here. * ipa-icf-gimple.c: Moved to... * ipa-icf-gimple.cc: ...here. * ipa-icf.c: Moved to... * ipa-icf.cc: ...here. * ipa-inline-analysis.c: Moved to... * ipa-inline-analysis.cc: ...here. * ipa-inline-transform.c: Moved to... * ipa-inline-transform.cc: ...here. * ipa-inline.c: Moved to... * ipa-inline.cc: ...here. * ipa-modref-tree.c: Moved to... * ipa-modref-tree.cc: ...here. * ipa-modref.c: Moved to... * ipa-modref.cc: ...here. * ipa-param-manipulation.c: Moved to... * ipa-param-manipulation.cc: ...here. * ipa-polymorphic-call.c: Moved to... * ipa-polymorphic-call.cc: ...here. * ipa-predicate.c: Moved to... * ipa-predicate.cc: ...here. * ipa-profile.c: Moved to... * ipa-profile.cc: ...here. * ipa-prop.c: Moved to... * ipa-prop.cc: ...here. * ipa-pure-const.c: Moved to... * ipa-pure-const.cc: ...here. * ipa-ref.c: Moved to... * ipa-ref.cc: ...here. * ipa-reference.c: Moved to... * ipa-reference.cc: ...here. * ipa-split.c: Moved to... * ipa-split.cc: ...here. * ipa-sra.c: Moved to... * ipa-sra.cc: ...here. * ipa-utils.c: Moved to... * ipa-utils.cc: ...here. * ipa-visibility.c: Moved to... * ipa-visibility.cc: ...here. * ipa.c: Moved to... * ipa.cc: ...here. * ira-build.c: Moved to... * ira-build.cc: ...here. * ira-color.c: Moved to... * ira-color.cc: ...here. * ira-conflicts.c: Moved to... * ira-conflicts.cc: ...here. * ira-costs.c: Moved to... * ira-costs.cc: ...here. * ira-emit.c: Moved to... * ira-emit.cc: ...here. * ira-lives.c: Moved to... * ira-lives.cc: ...here. * ira.c: Moved to... * ira.cc: ...here. * jump.c: Moved to... * jump.cc: ...here. * langhooks.c: Moved to... * langhooks.cc: ...here. * lcm.c: Moved to... * lcm.cc: ...here. * lists.c: Moved to... * lists.cc: ...here. * loop-doloop.c: Moved to... * loop-doloop.cc: ...here. * loop-init.c: Moved to... * loop-init.cc: ...here. * loop-invariant.c: Moved to... * loop-invariant.cc: ...here. * loop-iv.c: Moved to... * loop-iv.cc: ...here. * loop-unroll.c: Moved to... * loop-unroll.cc: ...here. * lower-subreg.c: Moved to... * lower-subreg.cc: ...here. * lra-assigns.c: Moved to... * lra-assigns.cc: ...here. * lra-coalesce.c: Moved to... * lra-coalesce.cc: ...here. * lra-constraints.c: Moved to... * lra-constraints.cc: ...here. * lra-eliminations.c: Moved to... * lra-eliminations.cc: ...here. * lra-lives.c: Moved to... * lra-lives.cc: ...here. * lra-remat.c: Moved to... * lra-remat.cc: ...here. * lra-spills.c: Moved to... * lra-spills.cc: ...here. * lra.c: Moved to... * lra.cc: ...here. * lto-cgraph.c: Moved to... * lto-cgraph.cc: ...here. * lto-compress.c: Moved to... * lto-compress.cc: ...here. * lto-opts.c: Moved to... * lto-opts.cc: ...here. * lto-section-in.c: Moved to... * lto-section-in.cc: ...here. * lto-section-out.c: Moved to... * lto-section-out.cc: ...here. * lto-streamer-in.c: Moved to... * lto-streamer-in.cc: ...here. * lto-streamer-out.c: Moved to... * lto-streamer-out.cc: ...here. * lto-streamer.c: Moved to... * lto-streamer.cc: ...here. * lto-wrapper.c: Moved to... * lto-wrapper.cc: ...here. * main.c: Moved to... * main.cc: ...here. * mcf.c: Moved to... * mcf.cc: ...here. * mode-switching.c: Moved to... * mode-switching.cc: ...here. * modulo-sched.c: Moved to... * modulo-sched.cc: ...here. * multiple_target.c: Moved to... * multiple_target.cc: ...here. * omp-expand.c: Moved to... * omp-expand.cc: ...here. * omp-general.c: Moved to... * omp-general.cc: ...here. * omp-low.c: Moved to... * omp-low.cc: ...here. * omp-offload.c: Moved to... * omp-offload.cc: ...here. * omp-simd-clone.c: Moved to... * omp-simd-clone.cc: ...here. * opt-suggestions.c: Moved to... * opt-suggestions.cc: ...here. * optabs-libfuncs.c: Moved to... * optabs-libfuncs.cc: ...here. * optabs-query.c: Moved to... * optabs-query.cc: ...here. * optabs-tree.c: Moved to... * optabs-tree.cc: ...here. * optabs.c: Moved to... * optabs.cc: ...here. * opts-common.c: Moved to... * opts-common.cc: ...here. * opts-global.c: Moved to... * opts-global.cc: ...here. * opts.c: Moved to... * opts.cc: ...here. * passes.c: Moved to... * passes.cc: ...here. * plugin.c: Moved to... * plugin.cc: ...here. * postreload-gcse.c: Moved to... * postreload-gcse.cc: ...here. * postreload.c: Moved to... * postreload.cc: ...here. * predict.c: Moved to... * predict.cc: ...here. * prefix.c: Moved to... * prefix.cc: ...here. * pretty-print.c: Moved to... * pretty-print.cc: ...here. * print-rtl-function.c: Moved to... * print-rtl-function.cc: ...here. * print-rtl.c: Moved to... * print-rtl.cc: ...here. * print-tree.c: Moved to... * print-tree.cc: ...here. * profile-count.c: Moved to... * profile-count.cc: ...here. * profile.c: Moved to... * profile.cc: ...here. * read-md.c: Moved to... * read-md.cc: ...here. * read-rtl-function.c: Moved to... * read-rtl-function.cc: ...here. * read-rtl.c: Moved to... * read-rtl.cc: ...here. * real.c: Moved to... * real.cc: ...here. * realmpfr.c: Moved to... * realmpfr.cc: ...here. * recog.c: Moved to... * recog.cc: ...here. * ree.c: Moved to... * ree.cc: ...here. * reg-stack.c: Moved to... * reg-stack.cc: ...here. * regcprop.c: Moved to... * regcprop.cc: ...here. * reginfo.c: Moved to... * reginfo.cc: ...here. * regrename.c: Moved to... * regrename.cc: ...here. * regstat.c: Moved to... * regstat.cc: ...here. * reload.c: Moved to... * reload.cc: ...here. * reload1.c: Moved to... * reload1.cc: ...here. * reorg.c: Moved to... * reorg.cc: ...here. * resource.c: Moved to... * resource.cc: ...here. * rtl-error.c: Moved to... * rtl-error.cc: ...here. * rtl-tests.c: Moved to... * rtl-tests.cc: ...here. * rtl.c: Moved to... * rtl.cc: ...here. * rtlanal.c: Moved to... * rtlanal.cc: ...here. * rtlhash.c: Moved to... * rtlhash.cc: ...here. * rtlhooks.c: Moved to... * rtlhooks.cc: ...here. * rtx-vector-builder.c: Moved to... * rtx-vector-builder.cc: ...here. * run-rtl-passes.c: Moved to... * run-rtl-passes.cc: ...here. * sancov.c: Moved to... * sancov.cc: ...here. * sanopt.c: Moved to... * sanopt.cc: ...here. * sbitmap.c: Moved to... * sbitmap.cc: ...here. * sched-deps.c: Moved to... * sched-deps.cc: ...here. * sched-ebb.c: Moved to... * sched-ebb.cc: ...here. * sched-rgn.c: Moved to... * sched-rgn.cc: ...here. * sel-sched-dump.c: Moved to... * sel-sched-dump.cc: ...here. * sel-sched-ir.c: Moved to... * sel-sched-ir.cc: ...here. * sel-sched.c: Moved to... * sel-sched.cc: ...here. * selftest-diagnostic.c: Moved to... * selftest-diagnostic.cc: ...here. * selftest-rtl.c: Moved to... * selftest-rtl.cc: ...here. * selftest-run-tests.c: Moved to... * selftest-run-tests.cc: ...here. * selftest.c: Moved to... * selftest.cc: ...here. * sese.c: Moved to... * sese.cc: ...here. * shrink-wrap.c: Moved to... * shrink-wrap.cc: ...here. * simplify-rtx.c: Moved to... * simplify-rtx.cc: ...here. * sparseset.c: Moved to... * sparseset.cc: ...here. * spellcheck-tree.c: Moved to... * spellcheck-tree.cc: ...here. * spellcheck.c: Moved to... * spellcheck.cc: ...here. * sreal.c: Moved to... * sreal.cc: ...here. * stack-ptr-mod.c: Moved to... * stack-ptr-mod.cc: ...here. * statistics.c: Moved to... * statistics.cc: ...here. * stmt.c: Moved to... * stmt.cc: ...here. * stor-layout.c: Moved to... * stor-layout.cc: ...here. * store-motion.c: Moved to... * store-motion.cc: ...here. * streamer-hooks.c: Moved to... * streamer-hooks.cc: ...here. * stringpool.c: Moved to... * stringpool.cc: ...here. * substring-locations.c: Moved to... * substring-locations.cc: ...here. * symtab.c: Moved to... * symtab.cc: ...here. * target-globals.c: Moved to... * target-globals.cc: ...here. * targhooks.c: Moved to... * targhooks.cc: ...here. * timevar.c: Moved to... * timevar.cc: ...here. * toplev.c: Moved to... * toplev.cc: ...here. * tracer.c: Moved to... * tracer.cc: ...here. * trans-mem.c: Moved to... * trans-mem.cc: ...here. * tree-affine.c: Moved to... * tree-affine.cc: ...here. * tree-call-cdce.c: Moved to... * tree-call-cdce.cc: ...here. * tree-cfg.c: Moved to... * tree-cfg.cc: ...here. * tree-cfgcleanup.c: Moved to... * tree-cfgcleanup.cc: ...here. * tree-chrec.c: Moved to... * tree-chrec.cc: ...here. * tree-complex.c: Moved to... * tree-complex.cc: ...here. * tree-data-ref.c: Moved to... * tree-data-ref.cc: ...here. * tree-dfa.c: Moved to... * tree-dfa.cc: ...here. * tree-diagnostic.c: Moved to... * tree-diagnostic.cc: ...here. * tree-dump.c: Moved to... * tree-dump.cc: ...here. * tree-eh.c: Moved to... * tree-eh.cc: ...here. * tree-emutls.c: Moved to... * tree-emutls.cc: ...here. * tree-if-conv.c: Moved to... * tree-if-conv.cc: ...here. * tree-inline.c: Moved to... * tree-inline.cc: ...here. * tree-into-ssa.c: Moved to... * tree-into-ssa.cc: ...here. * tree-iterator.c: Moved to... * tree-iterator.cc: ...here. * tree-loop-distribution.c: Moved to... * tree-loop-distribution.cc: ...here. * tree-nested.c: Moved to... * tree-nested.cc: ...here. * tree-nrv.c: Moved to... * tree-nrv.cc: ...here. * tree-object-size.c: Moved to... * tree-object-size.cc: ...here. * tree-outof-ssa.c: Moved to... * tree-outof-ssa.cc: ...here. * tree-parloops.c: Moved to... * tree-parloops.cc: ...here. * tree-phinodes.c: Moved to... * tree-phinodes.cc: ...here. * tree-predcom.c: Moved to... * tree-predcom.cc: ...here. * tree-pretty-print.c: Moved to... * tree-pretty-print.cc: ...here. * tree-profile.c: Moved to... * tree-profile.cc: ...here. * tree-scalar-evolution.c: Moved to... * tree-scalar-evolution.cc: ...here. * tree-sra.c: Moved to... * tree-sra.cc: ...here. * tree-ssa-address.c: Moved to... * tree-ssa-address.cc: ...here. * tree-ssa-alias.c: Moved to... * tree-ssa-alias.cc: ...here. * tree-ssa-ccp.c: Moved to... * tree-ssa-ccp.cc: ...here. * tree-ssa-coalesce.c: Moved to... * tree-ssa-coalesce.cc: ...here. * tree-ssa-copy.c: Moved to... * tree-ssa-copy.cc: ...here. * tree-ssa-dce.c: Moved to... * tree-ssa-dce.cc: ...here. * tree-ssa-dom.c: Moved to... * tree-ssa-dom.cc: ...here. * tree-ssa-dse.c: Moved to... * tree-ssa-dse.cc: ...here. * tree-ssa-forwprop.c: Moved to... * tree-ssa-forwprop.cc: ...here. * tree-ssa-ifcombine.c: Moved to... * tree-ssa-ifcombine.cc: ...here. * tree-ssa-live.c: Moved to... * tree-ssa-live.cc: ...here. * tree-ssa-loop-ch.c: Moved to... * tree-ssa-loop-ch.cc: ...here. * tree-ssa-loop-im.c: Moved to... * tree-ssa-loop-im.cc: ...here. * tree-ssa-loop-ivcanon.c: Moved to... * tree-ssa-loop-ivcanon.cc: ...here. * tree-ssa-loop-ivopts.c: Moved to... * tree-ssa-loop-ivopts.cc: ...here. * tree-ssa-loop-manip.c: Moved to... * tree-ssa-loop-manip.cc: ...here. * tree-ssa-loop-niter.c: Moved to... * tree-ssa-loop-niter.cc: ...here. * tree-ssa-loop-prefetch.c: Moved to... * tree-ssa-loop-prefetch.cc: ...here. * tree-ssa-loop-split.c: Moved to... * tree-ssa-loop-split.cc: ...here. * tree-ssa-loop-unswitch.c: Moved to... * tree-ssa-loop-unswitch.cc: ...here. * tree-ssa-loop.c: Moved to... * tree-ssa-loop.cc: ...here. * tree-ssa-math-opts.c: Moved to... * tree-ssa-math-opts.cc: ...here. * tree-ssa-operands.c: Moved to... * tree-ssa-operands.cc: ...here. * tree-ssa-phiopt.c: Moved to... * tree-ssa-phiopt.cc: ...here. * tree-ssa-phiprop.c: Moved to... * tree-ssa-phiprop.cc: ...here. * tree-ssa-pre.c: Moved to... * tree-ssa-pre.cc: ...here. * tree-ssa-propagate.c: Moved to... * tree-ssa-propagate.cc: ...here. * tree-ssa-reassoc.c: Moved to... * tree-ssa-reassoc.cc: ...here. * tree-ssa-sccvn.c: Moved to... * tree-ssa-sccvn.cc: ...here. * tree-ssa-scopedtables.c: Moved to... * tree-ssa-scopedtables.cc: ...here. * tree-ssa-sink.c: Moved to... * tree-ssa-sink.cc: ...here. * tree-ssa-strlen.c: Moved to... * tree-ssa-strlen.cc: ...here. * tree-ssa-structalias.c: Moved to... * tree-ssa-structalias.cc: ...here. * tree-ssa-tail-merge.c: Moved to... * tree-ssa-tail-merge.cc: ...here. * tree-ssa-ter.c: Moved to... * tree-ssa-ter.cc: ...here. * tree-ssa-threadbackward.c: Moved to... * tree-ssa-threadbackward.cc: ...here. * tree-ssa-threadedge.c: Moved to... * tree-ssa-threadedge.cc: ...here. * tree-ssa-threadupdate.c: Moved to... * tree-ssa-threadupdate.cc: ...here. * tree-ssa-uncprop.c: Moved to... * tree-ssa-uncprop.cc: ...here. * tree-ssa-uninit.c: Moved to... * tree-ssa-uninit.cc: ...here. * tree-ssa.c: Moved to... * tree-ssa.cc: ...here. * tree-ssanames.c: Moved to... * tree-ssanames.cc: ...here. * tree-stdarg.c: Moved to... * tree-stdarg.cc: ...here. * tree-streamer-in.c: Moved to... * tree-streamer-in.cc: ...here. * tree-streamer-out.c: Moved to... * tree-streamer-out.cc: ...here. * tree-streamer.c: Moved to... * tree-streamer.cc: ...here. * tree-switch-conversion.c: Moved to... * tree-switch-conversion.cc: ...here. * tree-tailcall.c: Moved to... * tree-tailcall.cc: ...here. * tree-vect-data-refs.c: Moved to... * tree-vect-data-refs.cc: ...here. * tree-vect-generic.c: Moved to... * tree-vect-generic.cc: ...here. * tree-vect-loop-manip.c: Moved to... * tree-vect-loop-manip.cc: ...here. * tree-vect-loop.c: Moved to... * tree-vect-loop.cc: ...here. * tree-vect-patterns.c: Moved to... * tree-vect-patterns.cc: ...here. * tree-vect-slp-patterns.c: Moved to... * tree-vect-slp-patterns.cc: ...here. * tree-vect-slp.c: Moved to... * tree-vect-slp.cc: ...here. * tree-vect-stmts.c: Moved to... * tree-vect-stmts.cc: ...here. * tree-vector-builder.c: Moved to... * tree-vector-builder.cc: ...here. * tree-vectorizer.c: Moved to... * tree-vectorizer.cc: ...here. * tree-vrp.c: Moved to... * tree-vrp.cc: ...here. * tree.c: Moved to... * tree.cc: ...here. * tsan.c: Moved to... * tsan.cc: ...here. * typed-splay-tree.c: Moved to... * typed-splay-tree.cc: ...here. * ubsan.c: Moved to... * ubsan.cc: ...here. * valtrack.c: Moved to... * valtrack.cc: ...here. * value-prof.c: Moved to... * value-prof.cc: ...here. * var-tracking.c: Moved to... * var-tracking.cc: ...here. * varasm.c: Moved to... * varasm.cc: ...here. * varpool.c: Moved to... * varpool.cc: ...here. * vec-perm-indices.c: Moved to... * vec-perm-indices.cc: ...here. * vec.c: Moved to... * vec.cc: ...here. * vmsdbgout.c: Moved to... * vmsdbgout.cc: ...here. * vr-values.c: Moved to... * vr-values.cc: ...here. * vtable-verify.c: Moved to... * vtable-verify.cc: ...here. * web.c: Moved to... * web.cc: ...here. * xcoffout.c: Moved to... * xcoffout.cc: ...here. gcc/c-family/ChangeLog: * c-ada-spec.c: Moved to... * c-ada-spec.cc: ...here. * c-attribs.c: Moved to... * c-attribs.cc: ...here. * c-common.c: Moved to... * c-common.cc: ...here. * c-cppbuiltin.c: Moved to... * c-cppbuiltin.cc: ...here. * c-dump.c: Moved to... * c-dump.cc: ...here. * c-format.c: Moved to... * c-format.cc: ...here. * c-gimplify.c: Moved to... * c-gimplify.cc: ...here. * c-indentation.c: Moved to... * c-indentation.cc: ...here. * c-lex.c: Moved to... * c-lex.cc: ...here. * c-omp.c: Moved to... * c-omp.cc: ...here. * c-opts.c: Moved to... * c-opts.cc: ...here. * c-pch.c: Moved to... * c-pch.cc: ...here. * c-ppoutput.c: Moved to... * c-ppoutput.cc: ...here. * c-pragma.c: Moved to... * c-pragma.cc: ...here. * c-pretty-print.c: Moved to... * c-pretty-print.cc: ...here. * c-semantics.c: Moved to... * c-semantics.cc: ...here. * c-ubsan.c: Moved to... * c-ubsan.cc: ...here. * c-warn.c: Moved to... * c-warn.cc: ...here. * cppspec.c: Moved to... * cppspec.cc: ...here. * stub-objc.c: Moved to... * stub-objc.cc: ...here. gcc/c/ChangeLog: * c-aux-info.c: Moved to... * c-aux-info.cc: ...here. * c-convert.c: Moved to... * c-convert.cc: ...here. * c-decl.c: Moved to... * c-decl.cc: ...here. * c-errors.c: Moved to... * c-errors.cc: ...here. * c-fold.c: Moved to... * c-fold.cc: ...here. * c-lang.c: Moved to... * c-lang.cc: ...here. * c-objc-common.c: Moved to... * c-objc-common.cc: ...here. * c-parser.c: Moved to... * c-parser.cc: ...here. * c-typeck.c: Moved to... * c-typeck.cc: ...here. * gccspec.c: Moved to... * gccspec.cc: ...here. * gimple-parser.c: Moved to... * gimple-parser.cc: ...here. gcc/cp/ChangeLog: * call.c: Moved to... * call.cc: ...here. * class.c: Moved to... * class.cc: ...here. * constexpr.c: Moved to... * constexpr.cc: ...here. * cp-gimplify.c: Moved to... * cp-gimplify.cc: ...here. * cp-lang.c: Moved to... * cp-lang.cc: ...here. * cp-objcp-common.c: Moved to... * cp-objcp-common.cc: ...here. * cp-ubsan.c: Moved to... * cp-ubsan.cc: ...here. * cvt.c: Moved to... * cvt.cc: ...here. * cxx-pretty-print.c: Moved to... * cxx-pretty-print.cc: ...here. * decl.c: Moved to... * decl.cc: ...here. * decl2.c: Moved to... * decl2.cc: ...here. * dump.c: Moved to... * dump.cc: ...here. * error.c: Moved to... * error.cc: ...here. * except.c: Moved to... * except.cc: ...here. * expr.c: Moved to... * expr.cc: ...here. * friend.c: Moved to... * friend.cc: ...here. * g++spec.c: Moved to... * g++spec.cc: ...here. * init.c: Moved to... * init.cc: ...here. * lambda.c: Moved to... * lambda.cc: ...here. * lex.c: Moved to... * lex.cc: ...here. * mangle.c: Moved to... * mangle.cc: ...here. * method.c: Moved to... * method.cc: ...here. * name-lookup.c: Moved to... * name-lookup.cc: ...here. * optimize.c: Moved to... * optimize.cc: ...here. * parser.c: Moved to... * parser.cc: ...here. * pt.c: Moved to... * pt.cc: ...here. * ptree.c: Moved to... * ptree.cc: ...here. * rtti.c: Moved to... * rtti.cc: ...here. * search.c: Moved to... * search.cc: ...here. * semantics.c: Moved to... * semantics.cc: ...here. * tree.c: Moved to... * tree.cc: ...here. * typeck.c: Moved to... * typeck.cc: ...here. * typeck2.c: Moved to... * typeck2.cc: ...here. * vtable-class-hierarchy.c: Moved to... * vtable-class-hierarchy.cc: ...here. gcc/fortran/ChangeLog: * arith.c: Moved to... * arith.cc: ...here. * array.c: Moved to... * array.cc: ...here. * bbt.c: Moved to... * bbt.cc: ...here. * check.c: Moved to... * check.cc: ...here. * class.c: Moved to... * class.cc: ...here. * constructor.c: Moved to... * constructor.cc: ...here. * convert.c: Moved to... * convert.cc: ...here. * cpp.c: Moved to... * cpp.cc: ...here. * data.c: Moved to... * data.cc: ...here. * decl.c: Moved to... * decl.cc: ...here. * dependency.c: Moved to... * dependency.cc: ...here. * dump-parse-tree.c: Moved to... * dump-parse-tree.cc: ...here. * error.c: Moved to... * error.cc: ...here. * expr.c: Moved to... * expr.cc: ...here. * f95-lang.c: Moved to... * f95-lang.cc: ...here. * frontend-passes.c: Moved to... * frontend-passes.cc: ...here. * gfortranspec.c: Moved to... * gfortranspec.cc: ...here. * interface.c: Moved to... * interface.cc: ...here. * intrinsic.c: Moved to... * intrinsic.cc: ...here. * io.c: Moved to... * io.cc: ...here. * iresolve.c: Moved to... * iresolve.cc: ...here. * match.c: Moved to... * match.cc: ...here. * matchexp.c: Moved to... * matchexp.cc: ...here. * misc.c: Moved to... * misc.cc: ...here. * module.c: Moved to... * module.cc: ...here. * openmp.c: Moved to... * openmp.cc: ...here. * options.c: Moved to... * options.cc: ...here. * parse.c: Moved to... * parse.cc: ...here. * primary.c: Moved to... * primary.cc: ...here. * resolve.c: Moved to... * resolve.cc: ...here. * scanner.c: Moved to... * scanner.cc: ...here. * simplify.c: Moved to... * simplify.cc: ...here. * st.c: Moved to... * st.cc: ...here. * symbol.c: Moved to... * symbol.cc: ...here. * target-memory.c: Moved to... * target-memory.cc: ...here. * trans-array.c: Moved to... * trans-array.cc: ...here. * trans-common.c: Moved to... * trans-common.cc: ...here. * trans-const.c: Moved to... * trans-const.cc: ...here. * trans-decl.c: Moved to... * trans-decl.cc: ...here. * trans-expr.c: Moved to... * trans-expr.cc: ...here. * trans-intrinsic.c: Moved to... * trans-intrinsic.cc: ...here. * trans-io.c: Moved to... * trans-io.cc: ...here. * trans-openmp.c: Moved to... * trans-openmp.cc: ...here. * trans-stmt.c: Moved to... * trans-stmt.cc: ...here. * trans-types.c: Moved to... * trans-types.cc: ...here. * trans.c: Moved to... * trans.cc: ...here. gcc/go/ChangeLog: * go-backend.c: Moved to... * go-backend.cc: ...here. * go-lang.c: Moved to... * go-lang.cc: ...here. * gospec.c: Moved to... * gospec.cc: ...here. gcc/jit/ChangeLog: * dummy-frontend.c: Moved to... * dummy-frontend.cc: ...here. * jit-builtins.c: Moved to... * jit-builtins.cc: ...here. * jit-logging.c: Moved to... * jit-logging.cc: ...here. * jit-playback.c: Moved to... * jit-playback.cc: ...here. * jit-recording.c: Moved to... * jit-recording.cc: ...here. * jit-result.c: Moved to... * jit-result.cc: ...here. * jit-spec.c: Moved to... * jit-spec.cc: ...here. * jit-tempdir.c: Moved to... * jit-tempdir.cc: ...here. * jit-w32.c: Moved to... * jit-w32.cc: ...here. * libgccjit.c: Moved to... * libgccjit.cc: ...here. gcc/lto/ChangeLog: * common.c: Moved to... * common.cc: ...here. * lto-common.c: Moved to... * lto-common.cc: ...here. * lto-dump.c: Moved to... * lto-dump.cc: ...here. * lto-lang.c: Moved to... * lto-lang.cc: ...here. * lto-object.c: Moved to... * lto-object.cc: ...here. * lto-partition.c: Moved to... * lto-partition.cc: ...here. * lto-symtab.c: Moved to... * lto-symtab.cc: ...here. * lto.c: Moved to... * lto.cc: ...here. gcc/objc/ChangeLog: * objc-act.c: Moved to... * objc-act.cc: ...here. * objc-encoding.c: Moved to... * objc-encoding.cc: ...here. * objc-gnu-runtime-abi-01.c: Moved to... * objc-gnu-runtime-abi-01.cc: ...here. * objc-lang.c: Moved to... * objc-lang.cc: ...here. * objc-map.c: Moved to... * objc-map.cc: ...here. * objc-next-runtime-abi-01.c: Moved to... * objc-next-runtime-abi-01.cc: ...here. * objc-next-runtime-abi-02.c: Moved to... * objc-next-runtime-abi-02.cc: ...here. * objc-runtime-shared-support.c: Moved to... * objc-runtime-shared-support.cc: ...here. gcc/objcp/ChangeLog: * objcp-decl.c: Moved to... * objcp-decl.cc: ...here. * objcp-lang.c: Moved to... * objcp-lang.cc: ...here. libcpp/ChangeLog: * charset.c: Moved to... * charset.cc: ...here. * directives.c: Moved to... * directives.cc: ...here. * errors.c: Moved to... * errors.cc: ...here. * expr.c: Moved to... * expr.cc: ...here. * files.c: Moved to... * files.cc: ...here. * identifiers.c: Moved to... * identifiers.cc: ...here. * init.c: Moved to... * init.cc: ...here. * lex.c: Moved to... * lex.cc: ...here. * line-map.c: Moved to... * line-map.cc: ...here. * macro.c: Moved to... * macro.cc: ...here. * makeucnid.c: Moved to... * makeucnid.cc: ...here. * mkdeps.c: Moved to... * mkdeps.cc: ...here. * pch.c: Moved to... * pch.cc: ...here. * symtab.c: Moved to... * symtab.cc: ...here. * traditional.c: Moved to... * traditional.cc: ...here.
Diffstat (limited to 'gcc/tree-parloops.c')
-rw-r--r--gcc/tree-parloops.c4241
1 files changed, 0 insertions, 4241 deletions
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
deleted file mode 100644
index e2df7e1..0000000
--- a/gcc/tree-parloops.c
+++ /dev/null
@@ -1,4241 +0,0 @@
-/* Loop autoparallelization.
- Copyright (C) 2006-2022 Free Software Foundation, Inc.
- Contributed by Sebastian Pop <pop@cri.ensmp.fr>
- Zdenek Dvorak <dvorakz@suse.cz> and Razya Ladelsky <razya@il.ibm.com>.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 3, or (at your option) any later
-version.
-
-GCC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-#include "backend.h"
-#include "tree.h"
-#include "gimple.h"
-#include "cfghooks.h"
-#include "tree-pass.h"
-#include "ssa.h"
-#include "cgraph.h"
-#include "gimple-pretty-print.h"
-#include "fold-const.h"
-#include "gimplify.h"
-#include "gimple-iterator.h"
-#include "gimplify-me.h"
-#include "gimple-walk.h"
-#include "stor-layout.h"
-#include "tree-nested.h"
-#include "tree-cfg.h"
-#include "tree-ssa-loop-ivopts.h"
-#include "tree-ssa-loop-manip.h"
-#include "tree-ssa-loop-niter.h"
-#include "tree-ssa-loop.h"
-#include "tree-into-ssa.h"
-#include "cfgloop.h"
-#include "tree-scalar-evolution.h"
-#include "langhooks.h"
-#include "tree-vectorizer.h"
-#include "tree-hasher.h"
-#include "tree-parloops.h"
-#include "omp-general.h"
-#include "omp-low.h"
-#include "tree-ssa.h"
-#include "tree-ssa-alias.h"
-#include "tree-eh.h"
-#include "gomp-constants.h"
-#include "tree-dfa.h"
-#include "stringpool.h"
-#include "attribs.h"
-
-/* This pass tries to distribute iterations of loops into several threads.
- The implementation is straightforward -- for each loop we test whether its
- iterations are independent, and if it is the case (and some additional
- conditions regarding profitability and correctness are satisfied), we
- add GIMPLE_OMP_PARALLEL and GIMPLE_OMP_FOR codes and let omp expansion
- machinery do its job.
-
- The most of the complexity is in bringing the code into shape expected
- by the omp expanders:
- -- for GIMPLE_OMP_FOR, ensuring that the loop has only one induction
- variable and that the exit test is at the start of the loop body
- -- for GIMPLE_OMP_PARALLEL, replacing the references to local addressable
- variables by accesses through pointers, and breaking up ssa chains
- by storing the values incoming to the parallelized loop to a structure
- passed to the new function as an argument (something similar is done
- in omp gimplification, unfortunately only a small part of the code
- can be shared).
-
- TODO:
- -- if there are several parallelizable loops in a function, it may be
- possible to generate the threads just once (using synchronization to
- ensure that cross-loop dependences are obeyed).
- -- handling of common reduction patterns for outer loops.
-
- More info can also be found at http://gcc.gnu.org/wiki/AutoParInGCC */
-/*
- Reduction handling:
- currently we use code inspired by vect_force_simple_reduction to detect
- reduction patterns.
- The code transformation will be introduced by an example.
-
-
-parloop
-{
- int sum=1;
-
- for (i = 0; i < N; i++)
- {
- x[i] = i + 3;
- sum+=x[i];
- }
-}
-
-gimple-like code:
-header_bb:
-
- # sum_29 = PHI <sum_11(5), 1(3)>
- # i_28 = PHI <i_12(5), 0(3)>
- D.1795_8 = i_28 + 3;
- x[i_28] = D.1795_8;
- sum_11 = D.1795_8 + sum_29;
- i_12 = i_28 + 1;
- if (N_6(D) > i_12)
- goto header_bb;
-
-
-exit_bb:
-
- # sum_21 = PHI <sum_11(4)>
- printf (&"%d"[0], sum_21);
-
-
-after reduction transformation (only relevant parts):
-
-parloop
-{
-
-....
-
-
- # Storing the initial value given by the user. #
-
- .paral_data_store.32.sum.27 = 1;
-
- #pragma omp parallel num_threads(4)
-
- #pragma omp for schedule(static)
-
- # The neutral element corresponding to the particular
- reduction's operation, e.g. 0 for PLUS_EXPR,
- 1 for MULT_EXPR, etc. replaces the user's initial value. #
-
- # sum.27_29 = PHI <sum.27_11, 0>
-
- sum.27_11 = D.1827_8 + sum.27_29;
-
- GIMPLE_OMP_CONTINUE
-
- # Adding this reduction phi is done at create_phi_for_local_result() #
- # sum.27_56 = PHI <sum.27_11, 0>
- GIMPLE_OMP_RETURN
-
- # Creating the atomic operation is done at
- create_call_for_reduction_1() #
-
- #pragma omp atomic_load
- D.1839_59 = *&.paral_data_load.33_51->reduction.23;
- D.1840_60 = sum.27_56 + D.1839_59;
- #pragma omp atomic_store (D.1840_60);
-
- GIMPLE_OMP_RETURN
-
- # collecting the result after the join of the threads is done at
- create_loads_for_reductions().
- The value computed by the threads is loaded from the
- shared struct. #
-
-
- .paral_data_load.33_52 = &.paral_data_store.32;
- sum_37 = .paral_data_load.33_52->sum.27;
- sum_43 = D.1795_41 + sum_37;
-
- exit bb:
- # sum_21 = PHI <sum_43, sum_26>
- printf (&"%d"[0], sum_21);
-
-...
-
-}
-
-*/
-
-/* Error reporting helper for parloops_is_simple_reduction below. GIMPLE
- statement STMT is printed with a message MSG. */
-
-static void
-report_ploop_op (dump_flags_t msg_type, gimple *stmt, const char *msg)
-{
- dump_printf_loc (msg_type, vect_location, "%s%G", msg, stmt);
-}
-
-/* DEF_STMT_INFO occurs in a loop that contains a potential reduction
- operation. Return true if the results of DEF_STMT_INFO are something
- that can be accumulated by such a reduction. */
-
-static bool
-parloops_valid_reduction_input_p (stmt_vec_info def_stmt_info)
-{
- return (is_gimple_assign (def_stmt_info->stmt)
- || is_gimple_call (def_stmt_info->stmt)
- || STMT_VINFO_DEF_TYPE (def_stmt_info) == vect_induction_def
- || (gimple_code (def_stmt_info->stmt) == GIMPLE_PHI
- && STMT_VINFO_DEF_TYPE (def_stmt_info) == vect_internal_def
- && !is_loop_header_bb_p (gimple_bb (def_stmt_info->stmt))));
-}
-
-/* Detect SLP reduction of the form:
-
- #a1 = phi <a5, a0>
- a2 = operation (a1)
- a3 = operation (a2)
- a4 = operation (a3)
- a5 = operation (a4)
-
- #a = phi <a5>
-
- PHI is the reduction phi node (#a1 = phi <a5, a0> above)
- FIRST_STMT is the first reduction stmt in the chain
- (a2 = operation (a1)).
-
- Return TRUE if a reduction chain was detected. */
-
-static bool
-parloops_is_slp_reduction (loop_vec_info loop_info, gimple *phi,
- gimple *first_stmt)
-{
- class loop *loop = (gimple_bb (phi))->loop_father;
- class loop *vect_loop = LOOP_VINFO_LOOP (loop_info);
- enum tree_code code;
- gimple *loop_use_stmt = NULL;
- stmt_vec_info use_stmt_info;
- tree lhs;
- imm_use_iterator imm_iter;
- use_operand_p use_p;
- int nloop_uses, size = 0, n_out_of_loop_uses;
- bool found = false;
-
- if (loop != vect_loop)
- return false;
-
- auto_vec<stmt_vec_info, 8> reduc_chain;
- lhs = PHI_RESULT (phi);
- code = gimple_assign_rhs_code (first_stmt);
- while (1)
- {
- nloop_uses = 0;
- n_out_of_loop_uses = 0;
- FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs)
- {
- gimple *use_stmt = USE_STMT (use_p);
- if (is_gimple_debug (use_stmt))
- continue;
-
- /* Check if we got back to the reduction phi. */
- if (use_stmt == phi)
- {
- loop_use_stmt = use_stmt;
- found = true;
- break;
- }
-
- if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
- {
- loop_use_stmt = use_stmt;
- nloop_uses++;
- }
- else
- n_out_of_loop_uses++;
-
- /* There are can be either a single use in the loop or two uses in
- phi nodes. */
- if (nloop_uses > 1 || (n_out_of_loop_uses && nloop_uses))
- return false;
- }
-
- if (found)
- break;
-
- /* We reached a statement with no loop uses. */
- if (nloop_uses == 0)
- return false;
-
- /* This is a loop exit phi, and we haven't reached the reduction phi. */
- if (gimple_code (loop_use_stmt) == GIMPLE_PHI)
- return false;
-
- if (!is_gimple_assign (loop_use_stmt)
- || code != gimple_assign_rhs_code (loop_use_stmt)
- || !flow_bb_inside_loop_p (loop, gimple_bb (loop_use_stmt)))
- return false;
-
- /* Insert USE_STMT into reduction chain. */
- use_stmt_info = loop_info->lookup_stmt (loop_use_stmt);
- reduc_chain.safe_push (use_stmt_info);
-
- lhs = gimple_assign_lhs (loop_use_stmt);
- size++;
- }
-
- if (!found || loop_use_stmt != phi || size < 2)
- return false;
-
- /* Swap the operands, if needed, to make the reduction operand be the second
- operand. */
- lhs = PHI_RESULT (phi);
- for (unsigned i = 0; i < reduc_chain.length (); ++i)
- {
- gassign *next_stmt = as_a <gassign *> (reduc_chain[i]->stmt);
- if (gimple_assign_rhs2 (next_stmt) == lhs)
- {
- tree op = gimple_assign_rhs1 (next_stmt);
- stmt_vec_info def_stmt_info = loop_info->lookup_def (op);
-
- /* Check that the other def is either defined in the loop
- ("vect_internal_def"), or it's an induction (defined by a
- loop-header phi-node). */
- if (def_stmt_info
- && flow_bb_inside_loop_p (loop, gimple_bb (def_stmt_info->stmt))
- && parloops_valid_reduction_input_p (def_stmt_info))
- {
- lhs = gimple_assign_lhs (next_stmt);
- continue;
- }
-
- return false;
- }
- else
- {
- tree op = gimple_assign_rhs2 (next_stmt);
- stmt_vec_info def_stmt_info = loop_info->lookup_def (op);
-
- /* Check that the other def is either defined in the loop
- ("vect_internal_def"), or it's an induction (defined by a
- loop-header phi-node). */
- if (def_stmt_info
- && flow_bb_inside_loop_p (loop, gimple_bb (def_stmt_info->stmt))
- && parloops_valid_reduction_input_p (def_stmt_info))
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_NOTE, vect_location, "swapping oprnds: %G",
- next_stmt);
-
- swap_ssa_operands (next_stmt,
- gimple_assign_rhs1_ptr (next_stmt),
- gimple_assign_rhs2_ptr (next_stmt));
- update_stmt (next_stmt);
- }
- else
- return false;
- }
-
- lhs = gimple_assign_lhs (next_stmt);
- }
-
- /* Build up the actual chain. */
- for (unsigned i = 0; i < reduc_chain.length () - 1; ++i)
- {
- REDUC_GROUP_FIRST_ELEMENT (reduc_chain[i]) = reduc_chain[0];
- REDUC_GROUP_NEXT_ELEMENT (reduc_chain[i]) = reduc_chain[i+1];
- }
- REDUC_GROUP_FIRST_ELEMENT (reduc_chain.last ()) = reduc_chain[0];
- REDUC_GROUP_NEXT_ELEMENT (reduc_chain.last ()) = NULL;
-
- /* Save the chain for further analysis in SLP detection. */
- LOOP_VINFO_REDUCTION_CHAINS (loop_info).safe_push (reduc_chain[0]);
- REDUC_GROUP_SIZE (reduc_chain[0]) = size;
-
- return true;
-}
-
-/* Return true if we need an in-order reduction for operation CODE
- on type TYPE. NEED_WRAPPING_INTEGRAL_OVERFLOW is true if integer
- overflow must wrap. */
-
-static bool
-parloops_needs_fold_left_reduction_p (tree type, tree_code code,
- bool need_wrapping_integral_overflow)
-{
- /* CHECKME: check for !flag_finite_math_only too? */
- if (SCALAR_FLOAT_TYPE_P (type))
- switch (code)
- {
- case MIN_EXPR:
- case MAX_EXPR:
- return false;
-
- default:
- return !flag_associative_math;
- }
-
- if (INTEGRAL_TYPE_P (type))
- {
- if (!operation_no_trapping_overflow (type, code))
- return true;
- if (need_wrapping_integral_overflow
- && !TYPE_OVERFLOW_WRAPS (type)
- && operation_can_overflow (code))
- return true;
- return false;
- }
-
- if (SAT_FIXED_POINT_TYPE_P (type))
- return true;
-
- return false;
-}
-
-
-/* Function parloops_is_simple_reduction
-
- (1) Detect a cross-iteration def-use cycle that represents a simple
- reduction computation. We look for the following pattern:
-
- loop_header:
- a1 = phi < a0, a2 >
- a3 = ...
- a2 = operation (a3, a1)
-
- or
-
- a3 = ...
- loop_header:
- a1 = phi < a0, a2 >
- a2 = operation (a3, a1)
-
- such that:
- 1. operation is commutative and associative and it is safe to
- change the order of the computation
- 2. no uses for a2 in the loop (a2 is used out of the loop)
- 3. no uses of a1 in the loop besides the reduction operation
- 4. no uses of a1 outside the loop.
-
- Conditions 1,4 are tested here.
- Conditions 2,3 are tested in vect_mark_stmts_to_be_vectorized.
-
- (2) Detect a cross-iteration def-use cycle in nested loops, i.e.,
- nested cycles.
-
- (3) Detect cycles of phi nodes in outer-loop vectorization, i.e., double
- reductions:
-
- a1 = phi < a0, a2 >
- inner loop (def of a3)
- a2 = phi < a3 >
-
- (4) Detect condition expressions, ie:
- for (int i = 0; i < N; i++)
- if (a[i] < val)
- ret_val = a[i];
-
-*/
-
-static stmt_vec_info
-parloops_is_simple_reduction (loop_vec_info loop_info, stmt_vec_info phi_info,
- bool *double_reduc,
- bool need_wrapping_integral_overflow,
- enum vect_reduction_type *v_reduc_type)
-{
- gphi *phi = as_a <gphi *> (phi_info->stmt);
- class loop *loop = (gimple_bb (phi))->loop_father;
- class loop *vect_loop = LOOP_VINFO_LOOP (loop_info);
- bool nested_in_vect_loop = flow_loop_nested_p (vect_loop, loop);
- gimple *phi_use_stmt = NULL;
- enum tree_code orig_code, code;
- tree op1, op2, op3 = NULL_TREE, op4 = NULL_TREE;
- tree type;
- tree name;
- imm_use_iterator imm_iter;
- use_operand_p use_p;
- bool phi_def;
-
- *double_reduc = false;
- *v_reduc_type = TREE_CODE_REDUCTION;
-
- tree phi_name = PHI_RESULT (phi);
- /* ??? If there are no uses of the PHI result the inner loop reduction
- won't be detected as possibly double-reduction by vectorizable_reduction
- because that tries to walk the PHI arg from the preheader edge which
- can be constant. See PR60382. */
- if (has_zero_uses (phi_name))
- return NULL;
- unsigned nphi_def_loop_uses = 0;
- FOR_EACH_IMM_USE_FAST (use_p, imm_iter, phi_name)
- {
- gimple *use_stmt = USE_STMT (use_p);
- if (is_gimple_debug (use_stmt))
- continue;
-
- if (!flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "intermediate value used outside loop.\n");
-
- return NULL;
- }
-
- nphi_def_loop_uses++;
- phi_use_stmt = use_stmt;
- }
-
- edge latch_e = loop_latch_edge (loop);
- tree loop_arg = PHI_ARG_DEF_FROM_EDGE (phi, latch_e);
- if (TREE_CODE (loop_arg) != SSA_NAME)
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "reduction: not ssa_name: %T\n", loop_arg);
- return NULL;
- }
-
- stmt_vec_info def_stmt_info = loop_info->lookup_def (loop_arg);
- if (!def_stmt_info
- || !flow_bb_inside_loop_p (loop, gimple_bb (def_stmt_info->stmt)))
- return NULL;
-
- if (gassign *def_stmt = dyn_cast <gassign *> (def_stmt_info->stmt))
- {
- name = gimple_assign_lhs (def_stmt);
- phi_def = false;
- }
- else if (gphi *def_stmt = dyn_cast <gphi *> (def_stmt_info->stmt))
- {
- name = PHI_RESULT (def_stmt);
- phi_def = true;
- }
- else
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "reduction: unhandled reduction operation: %G",
- def_stmt_info->stmt);
- return NULL;
- }
-
- unsigned nlatch_def_loop_uses = 0;
- auto_vec<gphi *, 3> lcphis;
- bool inner_loop_of_double_reduc = false;
- FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name)
- {
- gimple *use_stmt = USE_STMT (use_p);
- if (is_gimple_debug (use_stmt))
- continue;
- if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
- nlatch_def_loop_uses++;
- else
- {
- /* We can have more than one loop-closed PHI. */
- lcphis.safe_push (as_a <gphi *> (use_stmt));
- if (nested_in_vect_loop
- && (STMT_VINFO_DEF_TYPE (loop_info->lookup_stmt (use_stmt))
- == vect_double_reduction_def))
- inner_loop_of_double_reduc = true;
- }
- }
-
- /* If this isn't a nested cycle or if the nested cycle reduction value
- is used ouside of the inner loop we cannot handle uses of the reduction
- value. */
- if ((!nested_in_vect_loop || inner_loop_of_double_reduc)
- && (nlatch_def_loop_uses > 1 || nphi_def_loop_uses > 1))
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "reduction used in loop.\n");
- return NULL;
- }
-
- /* If DEF_STMT is a phi node itself, we expect it to have a single argument
- defined in the inner loop. */
- if (phi_def)
- {
- gphi *def_stmt = as_a <gphi *> (def_stmt_info->stmt);
- op1 = PHI_ARG_DEF (def_stmt, 0);
-
- if (gimple_phi_num_args (def_stmt) != 1
- || TREE_CODE (op1) != SSA_NAME)
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "unsupported phi node definition.\n");
-
- return NULL;
- }
-
- gimple *def1 = SSA_NAME_DEF_STMT (op1);
- if (gimple_bb (def1)
- && flow_bb_inside_loop_p (loop, gimple_bb (def_stmt))
- && loop->inner
- && flow_bb_inside_loop_p (loop->inner, gimple_bb (def1))
- && is_gimple_assign (def1)
- && is_a <gphi *> (phi_use_stmt)
- && flow_bb_inside_loop_p (loop->inner, gimple_bb (phi_use_stmt)))
- {
- if (dump_enabled_p ())
- report_ploop_op (MSG_NOTE, def_stmt,
- "detected double reduction: ");
-
- *double_reduc = true;
- return def_stmt_info;
- }
-
- return NULL;
- }
-
- /* If we are vectorizing an inner reduction we are executing that
- in the original order only in case we are not dealing with a
- double reduction. */
- bool check_reduction = true;
- if (flow_loop_nested_p (vect_loop, loop))
- {
- gphi *lcphi;
- unsigned i;
- check_reduction = false;
- FOR_EACH_VEC_ELT (lcphis, i, lcphi)
- FOR_EACH_IMM_USE_FAST (use_p, imm_iter, gimple_phi_result (lcphi))
- {
- gimple *use_stmt = USE_STMT (use_p);
- if (is_gimple_debug (use_stmt))
- continue;
- if (! flow_bb_inside_loop_p (vect_loop, gimple_bb (use_stmt)))
- check_reduction = true;
- }
- }
-
- gassign *def_stmt = as_a <gassign *> (def_stmt_info->stmt);
- code = orig_code = gimple_assign_rhs_code (def_stmt);
-
- if (nested_in_vect_loop && !check_reduction)
- {
- /* FIXME: Even for non-reductions code generation is funneled
- through vectorizable_reduction for the stmt defining the
- PHI latch value. So we have to artificially restrict ourselves
- for the supported operations. */
- switch (get_gimple_rhs_class (code))
- {
- case GIMPLE_BINARY_RHS:
- case GIMPLE_TERNARY_RHS:
- break;
- default:
- /* Not supported by vectorizable_reduction. */
- if (dump_enabled_p ())
- report_ploop_op (MSG_MISSED_OPTIMIZATION, def_stmt,
- "nested cycle: not handled operation: ");
- return NULL;
- }
- if (dump_enabled_p ())
- report_ploop_op (MSG_NOTE, def_stmt, "detected nested cycle: ");
- return def_stmt_info;
- }
-
- /* We can handle "res -= x[i]", which is non-associative by
- simply rewriting this into "res += -x[i]". Avoid changing
- gimple instruction for the first simple tests and only do this
- if we're allowed to change code at all. */
- if (code == MINUS_EXPR && gimple_assign_rhs2 (def_stmt) != phi_name)
- code = PLUS_EXPR;
-
- if (code == COND_EXPR)
- {
- if (! nested_in_vect_loop)
- *v_reduc_type = COND_REDUCTION;
-
- op3 = gimple_assign_rhs1 (def_stmt);
- if (COMPARISON_CLASS_P (op3))
- {
- op4 = TREE_OPERAND (op3, 1);
- op3 = TREE_OPERAND (op3, 0);
- }
- if (op3 == phi_name || op4 == phi_name)
- {
- if (dump_enabled_p ())
- report_ploop_op (MSG_MISSED_OPTIMIZATION, def_stmt,
- "reduction: condition depends on previous"
- " iteration: ");
- return NULL;
- }
-
- op1 = gimple_assign_rhs2 (def_stmt);
- op2 = gimple_assign_rhs3 (def_stmt);
- }
- else if (!commutative_tree_code (code) || !associative_tree_code (code))
- {
- if (dump_enabled_p ())
- report_ploop_op (MSG_MISSED_OPTIMIZATION, def_stmt,
- "reduction: not commutative/associative: ");
- return NULL;
- }
- else if (get_gimple_rhs_class (code) == GIMPLE_BINARY_RHS)
- {
- op1 = gimple_assign_rhs1 (def_stmt);
- op2 = gimple_assign_rhs2 (def_stmt);
- }
- else
- {
- if (dump_enabled_p ())
- report_ploop_op (MSG_MISSED_OPTIMIZATION, def_stmt,
- "reduction: not handled operation: ");
- return NULL;
- }
-
- if (TREE_CODE (op1) != SSA_NAME && TREE_CODE (op2) != SSA_NAME)
- {
- if (dump_enabled_p ())
- report_ploop_op (MSG_MISSED_OPTIMIZATION, def_stmt,
- "reduction: both uses not ssa_names: ");
-
- return NULL;
- }
-
- type = TREE_TYPE (gimple_assign_lhs (def_stmt));
- if ((TREE_CODE (op1) == SSA_NAME
- && !types_compatible_p (type,TREE_TYPE (op1)))
- || (TREE_CODE (op2) == SSA_NAME
- && !types_compatible_p (type, TREE_TYPE (op2)))
- || (op3 && TREE_CODE (op3) == SSA_NAME
- && !types_compatible_p (type, TREE_TYPE (op3)))
- || (op4 && TREE_CODE (op4) == SSA_NAME
- && !types_compatible_p (type, TREE_TYPE (op4))))
- {
- if (dump_enabled_p ())
- {
- dump_printf_loc (MSG_NOTE, vect_location,
- "reduction: multiple types: operation type: "
- "%T, operands types: %T,%T",
- type, TREE_TYPE (op1), TREE_TYPE (op2));
- if (op3)
- dump_printf (MSG_NOTE, ",%T", TREE_TYPE (op3));
-
- if (op4)
- dump_printf (MSG_NOTE, ",%T", TREE_TYPE (op4));
- dump_printf (MSG_NOTE, "\n");
- }
-
- return NULL;
- }
-
- /* Check whether it's ok to change the order of the computation.
- Generally, when vectorizing a reduction we change the order of the
- computation. This may change the behavior of the program in some
- cases, so we need to check that this is ok. One exception is when
- vectorizing an outer-loop: the inner-loop is executed sequentially,
- and therefore vectorizing reductions in the inner-loop during
- outer-loop vectorization is safe. */
- if (check_reduction
- && *v_reduc_type == TREE_CODE_REDUCTION
- && parloops_needs_fold_left_reduction_p (type, code,
- need_wrapping_integral_overflow))
- *v_reduc_type = FOLD_LEFT_REDUCTION;
-
- /* Reduction is safe. We're dealing with one of the following:
- 1) integer arithmetic and no trapv
- 2) floating point arithmetic, and special flags permit this optimization
- 3) nested cycle (i.e., outer loop vectorization). */
- stmt_vec_info def1_info = loop_info->lookup_def (op1);
- stmt_vec_info def2_info = loop_info->lookup_def (op2);
- if (code != COND_EXPR && !def1_info && !def2_info)
- {
- if (dump_enabled_p ())
- report_ploop_op (MSG_NOTE, def_stmt,
- "reduction: no defs for operands: ");
- return NULL;
- }
-
- /* Check that one def is the reduction def, defined by PHI,
- the other def is either defined in the loop ("vect_internal_def"),
- or it's an induction (defined by a loop-header phi-node). */
-
- if (def2_info
- && def2_info->stmt == phi
- && (code == COND_EXPR
- || !def1_info
- || !flow_bb_inside_loop_p (loop, gimple_bb (def1_info->stmt))
- || parloops_valid_reduction_input_p (def1_info)))
- {
- if (dump_enabled_p ())
- report_ploop_op (MSG_NOTE, def_stmt, "detected reduction: ");
- return def_stmt_info;
- }
-
- if (def1_info
- && def1_info->stmt == phi
- && (code == COND_EXPR
- || !def2_info
- || !flow_bb_inside_loop_p (loop, gimple_bb (def2_info->stmt))
- || parloops_valid_reduction_input_p (def2_info)))
- {
- if (! nested_in_vect_loop && orig_code != MINUS_EXPR)
- {
- /* Check if we can swap operands (just for simplicity - so that
- the rest of the code can assume that the reduction variable
- is always the last (second) argument). */
- if (code == COND_EXPR)
- {
- /* Swap cond_expr by inverting the condition. */
- tree cond_expr = gimple_assign_rhs1 (def_stmt);
- enum tree_code invert_code = ERROR_MARK;
- enum tree_code cond_code = TREE_CODE (cond_expr);
-
- if (TREE_CODE_CLASS (cond_code) == tcc_comparison)
- {
- bool honor_nans = HONOR_NANS (TREE_OPERAND (cond_expr, 0));
- invert_code = invert_tree_comparison (cond_code, honor_nans);
- }
- if (invert_code != ERROR_MARK)
- {
- TREE_SET_CODE (cond_expr, invert_code);
- swap_ssa_operands (def_stmt,
- gimple_assign_rhs2_ptr (def_stmt),
- gimple_assign_rhs3_ptr (def_stmt));
- }
- else
- {
- if (dump_enabled_p ())
- report_ploop_op (MSG_NOTE, def_stmt,
- "detected reduction: cannot swap operands "
- "for cond_expr");
- return NULL;
- }
- }
- else
- swap_ssa_operands (def_stmt, gimple_assign_rhs1_ptr (def_stmt),
- gimple_assign_rhs2_ptr (def_stmt));
-
- if (dump_enabled_p ())
- report_ploop_op (MSG_NOTE, def_stmt,
- "detected reduction: need to swap operands: ");
- }
- else
- {
- if (dump_enabled_p ())
- report_ploop_op (MSG_NOTE, def_stmt, "detected reduction: ");
- }
-
- return def_stmt_info;
- }
-
- /* Try to find SLP reduction chain. */
- if (! nested_in_vect_loop
- && code != COND_EXPR
- && orig_code != MINUS_EXPR
- && parloops_is_slp_reduction (loop_info, phi, def_stmt))
- {
- if (dump_enabled_p ())
- report_ploop_op (MSG_NOTE, def_stmt,
- "reduction: detected reduction chain: ");
-
- return def_stmt_info;
- }
-
- /* Look for the expression computing loop_arg from loop PHI result. */
- if (check_reduction_path (vect_location, loop, phi, loop_arg, code))
- return def_stmt_info;
-
- if (dump_enabled_p ())
- {
- report_ploop_op (MSG_MISSED_OPTIMIZATION, def_stmt,
- "reduction: unknown pattern: ");
- }
-
- return NULL;
-}
-
-/* Wrapper around vect_is_simple_reduction, which will modify code
- in-place if it enables detection of more reductions. Arguments
- as there. */
-
-stmt_vec_info
-parloops_force_simple_reduction (loop_vec_info loop_info, stmt_vec_info phi_info,
- bool *double_reduc,
- bool need_wrapping_integral_overflow)
-{
- enum vect_reduction_type v_reduc_type;
- stmt_vec_info def_info
- = parloops_is_simple_reduction (loop_info, phi_info, double_reduc,
- need_wrapping_integral_overflow,
- &v_reduc_type);
- if (def_info)
- {
- STMT_VINFO_REDUC_TYPE (phi_info) = v_reduc_type;
- STMT_VINFO_REDUC_DEF (phi_info) = def_info;
- STMT_VINFO_REDUC_TYPE (def_info) = v_reduc_type;
- STMT_VINFO_REDUC_DEF (def_info) = phi_info;
- }
- return def_info;
-}
-
-/* Minimal number of iterations of a loop that should be executed in each
- thread. */
-#define MIN_PER_THREAD param_parloops_min_per_thread
-
-/* Element of the hashtable, representing a
- reduction in the current loop. */
-struct reduction_info
-{
- gimple *reduc_stmt; /* reduction statement. */
- gimple *reduc_phi; /* The phi node defining the reduction. */
- enum tree_code reduction_code;/* code for the reduction operation. */
- unsigned reduc_version; /* SSA_NAME_VERSION of original reduc_phi
- result. */
- gphi *keep_res; /* The PHI_RESULT of this phi is the resulting value
- of the reduction variable when existing the loop. */
- tree initial_value; /* The initial value of the reduction var before entering the loop. */
- tree field; /* the name of the field in the parloop data structure intended for reduction. */
- tree reduc_addr; /* The address of the reduction variable for
- openacc reductions. */
- tree init; /* reduction initialization value. */
- gphi *new_phi; /* (helper field) Newly created phi node whose result
- will be passed to the atomic operation. Represents
- the local result each thread computed for the reduction
- operation. */
-};
-
-/* Reduction info hashtable helpers. */
-
-struct reduction_hasher : free_ptr_hash <reduction_info>
-{
- static inline hashval_t hash (const reduction_info *);
- static inline bool equal (const reduction_info *, const reduction_info *);
-};
-
-/* Equality and hash functions for hashtab code. */
-
-inline bool
-reduction_hasher::equal (const reduction_info *a, const reduction_info *b)
-{
- return (a->reduc_phi == b->reduc_phi);
-}
-
-inline hashval_t
-reduction_hasher::hash (const reduction_info *a)
-{
- return a->reduc_version;
-}
-
-typedef hash_table<reduction_hasher> reduction_info_table_type;
-
-
-static struct reduction_info *
-reduction_phi (reduction_info_table_type *reduction_list, gimple *phi)
-{
- struct reduction_info tmpred, *red;
-
- if (reduction_list->is_empty () || phi == NULL)
- return NULL;
-
- if (gimple_uid (phi) == (unsigned int)-1
- || gimple_uid (phi) == 0)
- return NULL;
-
- tmpred.reduc_phi = phi;
- tmpred.reduc_version = gimple_uid (phi);
- red = reduction_list->find (&tmpred);
- gcc_assert (red == NULL || red->reduc_phi == phi);
-
- return red;
-}
-
-/* Element of hashtable of names to copy. */
-
-struct name_to_copy_elt
-{
- unsigned version; /* The version of the name to copy. */
- tree new_name; /* The new name used in the copy. */
- tree field; /* The field of the structure used to pass the
- value. */
-};
-
-/* Name copies hashtable helpers. */
-
-struct name_to_copy_hasher : free_ptr_hash <name_to_copy_elt>
-{
- static inline hashval_t hash (const name_to_copy_elt *);
- static inline bool equal (const name_to_copy_elt *, const name_to_copy_elt *);
-};
-
-/* Equality and hash functions for hashtab code. */
-
-inline bool
-name_to_copy_hasher::equal (const name_to_copy_elt *a, const name_to_copy_elt *b)
-{
- return a->version == b->version;
-}
-
-inline hashval_t
-name_to_copy_hasher::hash (const name_to_copy_elt *a)
-{
- return (hashval_t) a->version;
-}
-
-typedef hash_table<name_to_copy_hasher> name_to_copy_table_type;
-
-/* A transformation matrix, which is a self-contained ROWSIZE x COLSIZE
- matrix. Rather than use floats, we simply keep a single DENOMINATOR that
- represents the denominator for every element in the matrix. */
-typedef struct lambda_trans_matrix_s
-{
- lambda_matrix matrix;
- int rowsize;
- int colsize;
- int denominator;
-} *lambda_trans_matrix;
-#define LTM_MATRIX(T) ((T)->matrix)
-#define LTM_ROWSIZE(T) ((T)->rowsize)
-#define LTM_COLSIZE(T) ((T)->colsize)
-#define LTM_DENOMINATOR(T) ((T)->denominator)
-
-/* Allocate a new transformation matrix. */
-
-static lambda_trans_matrix
-lambda_trans_matrix_new (int colsize, int rowsize,
- struct obstack * lambda_obstack)
-{
- lambda_trans_matrix ret;
-
- ret = (lambda_trans_matrix)
- obstack_alloc (lambda_obstack, sizeof (struct lambda_trans_matrix_s));
- LTM_MATRIX (ret) = lambda_matrix_new (rowsize, colsize, lambda_obstack);
- LTM_ROWSIZE (ret) = rowsize;
- LTM_COLSIZE (ret) = colsize;
- LTM_DENOMINATOR (ret) = 1;
- return ret;
-}
-
-/* Multiply a vector VEC by a matrix MAT.
- MAT is an M*N matrix, and VEC is a vector with length N. The result
- is stored in DEST which must be a vector of length M. */
-
-static void
-lambda_matrix_vector_mult (lambda_matrix matrix, int m, int n,
- lambda_vector vec, lambda_vector dest)
-{
- int i, j;
-
- lambda_vector_clear (dest, m);
- for (i = 0; i < m; i++)
- for (j = 0; j < n; j++)
- dest[i] += matrix[i][j] * vec[j];
-}
-
-/* Return true if TRANS is a legal transformation matrix that respects
- the dependence vectors in DISTS and DIRS. The conservative answer
- is false.
-
- "Wolfe proves that a unimodular transformation represented by the
- matrix T is legal when applied to a loop nest with a set of
- lexicographically non-negative distance vectors RDG if and only if
- for each vector d in RDG, (T.d >= 0) is lexicographically positive.
- i.e.: if and only if it transforms the lexicographically positive
- distance vectors to lexicographically positive vectors. Note that
- a unimodular matrix must transform the zero vector (and only it) to
- the zero vector." S.Muchnick. */
-
-static bool
-lambda_transform_legal_p (lambda_trans_matrix trans,
- int nb_loops,
- vec<ddr_p> dependence_relations)
-{
- unsigned int i, j;
- lambda_vector distres;
- struct data_dependence_relation *ddr;
-
- gcc_assert (LTM_COLSIZE (trans) == nb_loops
- && LTM_ROWSIZE (trans) == nb_loops);
-
- /* When there are no dependences, the transformation is correct. */
- if (dependence_relations.length () == 0)
- return true;
-
- ddr = dependence_relations[0];
- if (ddr == NULL)
- return true;
-
- /* When there is an unknown relation in the dependence_relations, we
- know that it is no worth looking at this loop nest: give up. */
- if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know)
- return false;
-
- distres = lambda_vector_new (nb_loops);
-
- /* For each distance vector in the dependence graph. */
- FOR_EACH_VEC_ELT (dependence_relations, i, ddr)
- {
- /* Don't care about relations for which we know that there is no
- dependence, nor about read-read (aka. output-dependences):
- these data accesses can happen in any order. */
- if (DDR_ARE_DEPENDENT (ddr) == chrec_known
- || (DR_IS_READ (DDR_A (ddr)) && DR_IS_READ (DDR_B (ddr))))
- continue;
-
- /* Conservatively answer: "this transformation is not valid". */
- if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know)
- return false;
-
- /* If the dependence could not be captured by a distance vector,
- conservatively answer that the transform is not valid. */
- if (DDR_NUM_DIST_VECTS (ddr) == 0)
- return false;
-
- /* Compute trans.dist_vect */
- for (j = 0; j < DDR_NUM_DIST_VECTS (ddr); j++)
- {
- lambda_matrix_vector_mult (LTM_MATRIX (trans), nb_loops, nb_loops,
- DDR_DIST_VECT (ddr, j), distres);
-
- if (!lambda_vector_lexico_pos (distres, nb_loops))
- return false;
- }
- }
- return true;
-}
-
-/* Data dependency analysis. Returns true if the iterations of LOOP
- are independent on each other (that is, if we can execute them
- in parallel). */
-
-static bool
-loop_parallel_p (class loop *loop, struct obstack * parloop_obstack)
-{
- vec<ddr_p> dependence_relations;
- vec<data_reference_p> datarefs;
- lambda_trans_matrix trans;
- bool ret = false;
-
- if (dump_file && (dump_flags & TDF_DETAILS))
- {
- fprintf (dump_file, "Considering loop %d\n", loop->num);
- if (!loop->inner)
- fprintf (dump_file, "loop is innermost\n");
- else
- fprintf (dump_file, "loop NOT innermost\n");
- }
-
- /* Check for problems with dependences. If the loop can be reversed,
- the iterations are independent. */
- auto_vec<loop_p, 3> loop_nest;
- datarefs.create (10);
- dependence_relations.create (100);
- if (! compute_data_dependences_for_loop (loop, true, &loop_nest, &datarefs,
- &dependence_relations))
- {
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, " FAILED: cannot analyze data dependencies\n");
- ret = false;
- goto end;
- }
- if (dump_file && (dump_flags & TDF_DETAILS))
- dump_data_dependence_relations (dump_file, dependence_relations);
-
- trans = lambda_trans_matrix_new (1, 1, parloop_obstack);
- LTM_MATRIX (trans)[0][0] = -1;
-
- if (lambda_transform_legal_p (trans, 1, dependence_relations))
- {
- ret = true;
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, " SUCCESS: may be parallelized\n");
- }
- else if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file,
- " FAILED: data dependencies exist across iterations\n");
-
- end:
- free_dependence_relations (dependence_relations);
- free_data_refs (datarefs);
-
- return ret;
-}
-
-/* Return true when LOOP contains basic blocks marked with the
- BB_IRREDUCIBLE_LOOP flag. */
-
-static inline bool
-loop_has_blocks_with_irreducible_flag (class loop *loop)
-{
- unsigned i;
- basic_block *bbs = get_loop_body_in_dom_order (loop);
- bool res = true;
-
- for (i = 0; i < loop->num_nodes; i++)
- if (bbs[i]->flags & BB_IRREDUCIBLE_LOOP)
- goto end;
-
- res = false;
- end:
- free (bbs);
- return res;
-}
-
-/* Assigns the address of OBJ in TYPE to an ssa name, and returns this name.
- The assignment statement is placed on edge ENTRY. DECL_ADDRESS maps decls
- to their addresses that can be reused. The address of OBJ is known to
- be invariant in the whole function. Other needed statements are placed
- right before GSI. */
-
-static tree
-take_address_of (tree obj, tree type, edge entry,
- int_tree_htab_type *decl_address, gimple_stmt_iterator *gsi)
-{
- int uid;
- tree *var_p, name, addr;
- gassign *stmt;
- gimple_seq stmts;
-
- /* Since the address of OBJ is invariant, the trees may be shared.
- Avoid rewriting unrelated parts of the code. */
- obj = unshare_expr (obj);
- for (var_p = &obj;
- handled_component_p (*var_p);
- var_p = &TREE_OPERAND (*var_p, 0))
- continue;
-
- /* Canonicalize the access to base on a MEM_REF. */
- if (DECL_P (*var_p))
- *var_p = build_simple_mem_ref (build_fold_addr_expr (*var_p));
-
- /* Assign a canonical SSA name to the address of the base decl used
- in the address and share it for all accesses and addresses based
- on it. */
- uid = DECL_UID (TREE_OPERAND (TREE_OPERAND (*var_p, 0), 0));
- int_tree_map elt;
- elt.uid = uid;
- int_tree_map *slot = decl_address->find_slot (elt, INSERT);
- if (!slot->to)
- {
- if (gsi == NULL)
- return NULL;
- addr = TREE_OPERAND (*var_p, 0);
- const char *obj_name
- = get_name (TREE_OPERAND (TREE_OPERAND (*var_p, 0), 0));
- if (obj_name)
- name = make_temp_ssa_name (TREE_TYPE (addr), NULL, obj_name);
- else
- name = make_ssa_name (TREE_TYPE (addr));
- stmt = gimple_build_assign (name, addr);
- gsi_insert_on_edge_immediate (entry, stmt);
-
- slot->uid = uid;
- slot->to = name;
- }
- else
- name = slot->to;
-
- /* Express the address in terms of the canonical SSA name. */
- TREE_OPERAND (*var_p, 0) = name;
- if (gsi == NULL)
- return build_fold_addr_expr_with_type (obj, type);
-
- name = force_gimple_operand (build_addr (obj),
- &stmts, true, NULL_TREE);
- if (!gimple_seq_empty_p (stmts))
- gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
-
- if (!useless_type_conversion_p (type, TREE_TYPE (name)))
- {
- name = force_gimple_operand (fold_convert (type, name), &stmts, true,
- NULL_TREE);
- if (!gimple_seq_empty_p (stmts))
- gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
- }
-
- return name;
-}
-
-static tree
-reduc_stmt_res (gimple *stmt)
-{
- return (gimple_code (stmt) == GIMPLE_PHI
- ? gimple_phi_result (stmt)
- : gimple_assign_lhs (stmt));
-}
-
-/* Callback for htab_traverse. Create the initialization statement
- for reduction described in SLOT, and place it at the preheader of
- the loop described in DATA. */
-
-int
-initialize_reductions (reduction_info **slot, class loop *loop)
-{
- tree init;
- tree type, arg;
- edge e;
-
- struct reduction_info *const reduc = *slot;
-
- /* Create initialization in preheader:
- reduction_variable = initialization value of reduction. */
-
- /* In the phi node at the header, replace the argument coming
- from the preheader with the reduction initialization value. */
-
- /* Initialize the reduction. */
- type = TREE_TYPE (PHI_RESULT (reduc->reduc_phi));
- init = omp_reduction_init_op (gimple_location (reduc->reduc_stmt),
- reduc->reduction_code, type);
- reduc->init = init;
-
- /* Replace the argument representing the initialization value
- with the initialization value for the reduction (neutral
- element for the particular operation, e.g. 0 for PLUS_EXPR,
- 1 for MULT_EXPR, etc).
- Keep the old value in a new variable "reduction_initial",
- that will be taken in consideration after the parallel
- computing is done. */
-
- e = loop_preheader_edge (loop);
- arg = PHI_ARG_DEF_FROM_EDGE (reduc->reduc_phi, e);
- /* Create new variable to hold the initial value. */
-
- SET_USE (PHI_ARG_DEF_PTR_FROM_EDGE
- (reduc->reduc_phi, loop_preheader_edge (loop)), init);
- reduc->initial_value = arg;
- return 1;
-}
-
-struct elv_data
-{
- struct walk_stmt_info info;
- edge entry;
- int_tree_htab_type *decl_address;
- gimple_stmt_iterator *gsi;
- bool changed;
- bool reset;
-};
-
-/* Eliminates references to local variables in *TP out of the single
- entry single exit region starting at DTA->ENTRY.
- DECL_ADDRESS contains addresses of the references that had their
- address taken already. If the expression is changed, CHANGED is
- set to true. Callback for walk_tree. */
-
-static tree
-eliminate_local_variables_1 (tree *tp, int *walk_subtrees, void *data)
-{
- struct elv_data *const dta = (struct elv_data *) data;
- tree t = *tp, var, addr, addr_type, type, obj;
-
- if (DECL_P (t))
- {
- *walk_subtrees = 0;
-
- if (!SSA_VAR_P (t) || DECL_EXTERNAL (t))
- return NULL_TREE;
-
- type = TREE_TYPE (t);
- addr_type = build_pointer_type (type);
- addr = take_address_of (t, addr_type, dta->entry, dta->decl_address,
- dta->gsi);
- if (dta->gsi == NULL && addr == NULL_TREE)
- {
- dta->reset = true;
- return NULL_TREE;
- }
-
- *tp = build_simple_mem_ref (addr);
-
- dta->changed = true;
- return NULL_TREE;
- }
-
- if (TREE_CODE (t) == ADDR_EXPR)
- {
- /* ADDR_EXPR may appear in two contexts:
- -- as a gimple operand, when the address taken is a function invariant
- -- as gimple rhs, when the resulting address in not a function
- invariant
- We do not need to do anything special in the latter case (the base of
- the memory reference whose address is taken may be replaced in the
- DECL_P case). The former case is more complicated, as we need to
- ensure that the new address is still a gimple operand. Thus, it
- is not sufficient to replace just the base of the memory reference --
- we need to move the whole computation of the address out of the
- loop. */
- if (!is_gimple_val (t))
- return NULL_TREE;
-
- *walk_subtrees = 0;
- obj = TREE_OPERAND (t, 0);
- var = get_base_address (obj);
- if (!var || !SSA_VAR_P (var) || DECL_EXTERNAL (var))
- return NULL_TREE;
-
- addr_type = TREE_TYPE (t);
- addr = take_address_of (obj, addr_type, dta->entry, dta->decl_address,
- dta->gsi);
- if (dta->gsi == NULL && addr == NULL_TREE)
- {
- dta->reset = true;
- return NULL_TREE;
- }
- *tp = addr;
-
- dta->changed = true;
- return NULL_TREE;
- }
-
- if (!EXPR_P (t))
- *walk_subtrees = 0;
-
- return NULL_TREE;
-}
-
-/* Moves the references to local variables in STMT at *GSI out of the single
- entry single exit region starting at ENTRY. DECL_ADDRESS contains
- addresses of the references that had their address taken
- already. */
-
-static void
-eliminate_local_variables_stmt (edge entry, gimple_stmt_iterator *gsi,
- int_tree_htab_type *decl_address)
-{
- struct elv_data dta;
- gimple *stmt = gsi_stmt (*gsi);
-
- memset (&dta.info, '\0', sizeof (dta.info));
- dta.entry = entry;
- dta.decl_address = decl_address;
- dta.changed = false;
- dta.reset = false;
-
- if (gimple_debug_bind_p (stmt))
- {
- dta.gsi = NULL;
- walk_tree (gimple_debug_bind_get_value_ptr (stmt),
- eliminate_local_variables_1, &dta.info, NULL);
- if (dta.reset)
- {
- gimple_debug_bind_reset_value (stmt);
- dta.changed = true;
- }
- }
- else if (gimple_clobber_p (stmt))
- {
- unlink_stmt_vdef (stmt);
- stmt = gimple_build_nop ();
- gsi_replace (gsi, stmt, false);
- dta.changed = true;
- }
- else
- {
- dta.gsi = gsi;
- walk_gimple_op (stmt, eliminate_local_variables_1, &dta.info);
- }
-
- if (dta.changed)
- update_stmt (stmt);
-}
-
-/* Eliminates the references to local variables from the single entry
- single exit region between the ENTRY and EXIT edges.
-
- This includes:
- 1) Taking address of a local variable -- these are moved out of the
- region (and temporary variable is created to hold the address if
- necessary).
-
- 2) Dereferencing a local variable -- these are replaced with indirect
- references. */
-
-static void
-eliminate_local_variables (edge entry, edge exit)
-{
- basic_block bb;
- auto_vec<basic_block, 3> body;
- unsigned i;
- gimple_stmt_iterator gsi;
- bool has_debug_stmt = false;
- int_tree_htab_type decl_address (10);
- basic_block entry_bb = entry->src;
- basic_block exit_bb = exit->dest;
-
- gather_blocks_in_sese_region (entry_bb, exit_bb, &body);
-
- FOR_EACH_VEC_ELT (body, i, bb)
- if (bb != entry_bb && bb != exit_bb)
- {
- for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
- if (is_gimple_debug (gsi_stmt (gsi)))
- {
- if (gimple_debug_bind_p (gsi_stmt (gsi)))
- has_debug_stmt = true;
- }
- else
- eliminate_local_variables_stmt (entry, &gsi, &decl_address);
- }
-
- if (has_debug_stmt)
- FOR_EACH_VEC_ELT (body, i, bb)
- if (bb != entry_bb && bb != exit_bb)
- for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
- if (gimple_debug_bind_p (gsi_stmt (gsi)))
- eliminate_local_variables_stmt (entry, &gsi, &decl_address);
-}
-
-/* Returns true if expression EXPR is not defined between ENTRY and
- EXIT, i.e. if all its operands are defined outside of the region. */
-
-static bool
-expr_invariant_in_region_p (edge entry, edge exit, tree expr)
-{
- basic_block entry_bb = entry->src;
- basic_block exit_bb = exit->dest;
- basic_block def_bb;
-
- if (is_gimple_min_invariant (expr))
- return true;
-
- if (TREE_CODE (expr) == SSA_NAME)
- {
- def_bb = gimple_bb (SSA_NAME_DEF_STMT (expr));
- if (def_bb
- && dominated_by_p (CDI_DOMINATORS, def_bb, entry_bb)
- && !dominated_by_p (CDI_DOMINATORS, def_bb, exit_bb))
- return false;
-
- return true;
- }
-
- return false;
-}
-
-/* If COPY_NAME_P is true, creates and returns a duplicate of NAME.
- The copies are stored to NAME_COPIES, if NAME was already duplicated,
- its duplicate stored in NAME_COPIES is returned.
-
- Regardless of COPY_NAME_P, the decl used as a base of the ssa name is also
- duplicated, storing the copies in DECL_COPIES. */
-
-static tree
-separate_decls_in_region_name (tree name, name_to_copy_table_type *name_copies,
- int_tree_htab_type *decl_copies,
- bool copy_name_p)
-{
- tree copy, var, var_copy;
- unsigned idx, uid, nuid;
- struct int_tree_map ielt;
- struct name_to_copy_elt elt, *nelt;
- name_to_copy_elt **slot;
- int_tree_map *dslot;
-
- if (TREE_CODE (name) != SSA_NAME)
- return name;
-
- idx = SSA_NAME_VERSION (name);
- elt.version = idx;
- slot = name_copies->find_slot_with_hash (&elt, idx,
- copy_name_p ? INSERT : NO_INSERT);
- if (slot && *slot)
- return (*slot)->new_name;
-
- if (copy_name_p)
- {
- copy = duplicate_ssa_name (name, NULL);
- nelt = XNEW (struct name_to_copy_elt);
- nelt->version = idx;
- nelt->new_name = copy;
- nelt->field = NULL_TREE;
- *slot = nelt;
- }
- else
- {
- gcc_assert (!slot);
- copy = name;
- }
-
- var = SSA_NAME_VAR (name);
- if (!var)
- return copy;
-
- uid = DECL_UID (var);
- ielt.uid = uid;
- dslot = decl_copies->find_slot_with_hash (ielt, uid, INSERT);
- if (!dslot->to)
- {
- var_copy = create_tmp_var (TREE_TYPE (var), get_name (var));
- DECL_NOT_GIMPLE_REG_P (var_copy) = DECL_NOT_GIMPLE_REG_P (var);
- dslot->uid = uid;
- dslot->to = var_copy;
-
- /* Ensure that when we meet this decl next time, we won't duplicate
- it again. */
- nuid = DECL_UID (var_copy);
- ielt.uid = nuid;
- dslot = decl_copies->find_slot_with_hash (ielt, nuid, INSERT);
- gcc_assert (!dslot->to);
- dslot->uid = nuid;
- dslot->to = var_copy;
- }
- else
- var_copy = dslot->to;
-
- replace_ssa_name_symbol (copy, var_copy);
- return copy;
-}
-
-/* Finds the ssa names used in STMT that are defined outside the
- region between ENTRY and EXIT and replaces such ssa names with
- their duplicates. The duplicates are stored to NAME_COPIES. Base
- decls of all ssa names used in STMT (including those defined in
- LOOP) are replaced with the new temporary variables; the
- replacement decls are stored in DECL_COPIES. */
-
-static void
-separate_decls_in_region_stmt (edge entry, edge exit, gimple *stmt,
- name_to_copy_table_type *name_copies,
- int_tree_htab_type *decl_copies)
-{
- use_operand_p use;
- def_operand_p def;
- ssa_op_iter oi;
- tree name, copy;
- bool copy_name_p;
-
- FOR_EACH_PHI_OR_STMT_DEF (def, stmt, oi, SSA_OP_DEF)
- {
- name = DEF_FROM_PTR (def);
- gcc_assert (TREE_CODE (name) == SSA_NAME);
- copy = separate_decls_in_region_name (name, name_copies, decl_copies,
- false);
- gcc_assert (copy == name);
- }
-
- FOR_EACH_PHI_OR_STMT_USE (use, stmt, oi, SSA_OP_USE)
- {
- name = USE_FROM_PTR (use);
- if (TREE_CODE (name) != SSA_NAME)
- continue;
-
- copy_name_p = expr_invariant_in_region_p (entry, exit, name);
- copy = separate_decls_in_region_name (name, name_copies, decl_copies,
- copy_name_p);
- SET_USE (use, copy);
- }
-}
-
-/* Finds the ssa names used in STMT that are defined outside the
- region between ENTRY and EXIT and replaces such ssa names with
- their duplicates. The duplicates are stored to NAME_COPIES. Base
- decls of all ssa names used in STMT (including those defined in
- LOOP) are replaced with the new temporary variables; the
- replacement decls are stored in DECL_COPIES. */
-
-static bool
-separate_decls_in_region_debug (gimple *stmt,
- name_to_copy_table_type *name_copies,
- int_tree_htab_type *decl_copies)
-{
- use_operand_p use;
- ssa_op_iter oi;
- tree var, name;
- struct int_tree_map ielt;
- struct name_to_copy_elt elt;
- name_to_copy_elt **slot;
- int_tree_map *dslot;
-
- if (gimple_debug_bind_p (stmt))
- var = gimple_debug_bind_get_var (stmt);
- else if (gimple_debug_source_bind_p (stmt))
- var = gimple_debug_source_bind_get_var (stmt);
- else
- return true;
- if (TREE_CODE (var) == DEBUG_EXPR_DECL || TREE_CODE (var) == LABEL_DECL)
- return true;
- gcc_assert (DECL_P (var) && SSA_VAR_P (var));
- ielt.uid = DECL_UID (var);
- dslot = decl_copies->find_slot_with_hash (ielt, ielt.uid, NO_INSERT);
- if (!dslot)
- return true;
- if (gimple_debug_bind_p (stmt))
- gimple_debug_bind_set_var (stmt, dslot->to);
- else if (gimple_debug_source_bind_p (stmt))
- gimple_debug_source_bind_set_var (stmt, dslot->to);
-
- FOR_EACH_PHI_OR_STMT_USE (use, stmt, oi, SSA_OP_USE)
- {
- name = USE_FROM_PTR (use);
- if (TREE_CODE (name) != SSA_NAME)
- continue;
-
- elt.version = SSA_NAME_VERSION (name);
- slot = name_copies->find_slot_with_hash (&elt, elt.version, NO_INSERT);
- if (!slot)
- {
- gimple_debug_bind_reset_value (stmt);
- update_stmt (stmt);
- break;
- }
-
- SET_USE (use, (*slot)->new_name);
- }
-
- return false;
-}
-
-/* Callback for htab_traverse. Adds a field corresponding to the reduction
- specified in SLOT. The type is passed in DATA. */
-
-int
-add_field_for_reduction (reduction_info **slot, tree type)
-{
-
- struct reduction_info *const red = *slot;
- tree var = reduc_stmt_res (red->reduc_stmt);
- tree field = build_decl (gimple_location (red->reduc_stmt), FIELD_DECL,
- SSA_NAME_IDENTIFIER (var), TREE_TYPE (var));
-
- insert_field_into_struct (type, field);
-
- red->field = field;
-
- return 1;
-}
-
-/* Callback for htab_traverse. Adds a field corresponding to a ssa name
- described in SLOT. The type is passed in DATA. */
-
-int
-add_field_for_name (name_to_copy_elt **slot, tree type)
-{
- struct name_to_copy_elt *const elt = *slot;
- tree name = ssa_name (elt->version);
- tree field = build_decl (UNKNOWN_LOCATION,
- FIELD_DECL, SSA_NAME_IDENTIFIER (name),
- TREE_TYPE (name));
-
- insert_field_into_struct (type, field);
- elt->field = field;
-
- return 1;
-}
-
-/* Callback for htab_traverse. A local result is the intermediate result
- computed by a single
- thread, or the initial value in case no iteration was executed.
- This function creates a phi node reflecting these values.
- The phi's result will be stored in NEW_PHI field of the
- reduction's data structure. */
-
-int
-create_phi_for_local_result (reduction_info **slot, class loop *loop)
-{
- struct reduction_info *const reduc = *slot;
- edge e;
- gphi *new_phi;
- basic_block store_bb, continue_bb;
- tree local_res;
- location_t locus;
-
- /* STORE_BB is the block where the phi
- should be stored. It is the destination of the loop exit.
- (Find the fallthru edge from GIMPLE_OMP_CONTINUE). */
- continue_bb = single_pred (loop->latch);
- store_bb = FALLTHRU_EDGE (continue_bb)->dest;
-
- /* STORE_BB has two predecessors. One coming from the loop
- (the reduction's result is computed at the loop),
- and another coming from a block preceding the loop,
- when no iterations
- are executed (the initial value should be taken). */
- if (EDGE_PRED (store_bb, 0) == FALLTHRU_EDGE (continue_bb))
- e = EDGE_PRED (store_bb, 1);
- else
- e = EDGE_PRED (store_bb, 0);
- tree lhs = reduc_stmt_res (reduc->reduc_stmt);
- local_res = copy_ssa_name (lhs);
- locus = gimple_location (reduc->reduc_stmt);
- new_phi = create_phi_node (local_res, store_bb);
- add_phi_arg (new_phi, reduc->init, e, locus);
- add_phi_arg (new_phi, lhs, FALLTHRU_EDGE (continue_bb), locus);
- reduc->new_phi = new_phi;
-
- return 1;
-}
-
-struct clsn_data
-{
- tree store;
- tree load;
-
- basic_block store_bb;
- basic_block load_bb;
-};
-
-/* Callback for htab_traverse. Create an atomic instruction for the
- reduction described in SLOT.
- DATA annotates the place in memory the atomic operation relates to,
- and the basic block it needs to be generated in. */
-
-int
-create_call_for_reduction_1 (reduction_info **slot, struct clsn_data *clsn_data)
-{
- struct reduction_info *const reduc = *slot;
- gimple_stmt_iterator gsi;
- tree type = TREE_TYPE (PHI_RESULT (reduc->reduc_phi));
- tree load_struct;
- basic_block bb;
- basic_block new_bb;
- edge e;
- tree t, addr, ref, x;
- tree tmp_load, name;
- gimple *load;
-
- if (reduc->reduc_addr == NULL_TREE)
- {
- load_struct = build_simple_mem_ref (clsn_data->load);
- t = build3 (COMPONENT_REF, type, load_struct, reduc->field, NULL_TREE);
-
- addr = build_addr (t);
- }
- else
- {
- /* Set the address for the atomic store. */
- addr = reduc->reduc_addr;
-
- /* Remove the non-atomic store '*addr = sum'. */
- tree res = PHI_RESULT (reduc->keep_res);
- use_operand_p use_p;
- gimple *stmt;
- bool single_use_p = single_imm_use (res, &use_p, &stmt);
- gcc_assert (single_use_p);
- replace_uses_by (gimple_vdef (stmt),
- gimple_vuse (stmt));
- gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
- gsi_remove (&gsi, true);
- }
-
- /* Create phi node. */
- bb = clsn_data->load_bb;
-
- gsi = gsi_last_bb (bb);
- e = split_block (bb, gsi_stmt (gsi));
- new_bb = e->dest;
-
- tmp_load = create_tmp_var (TREE_TYPE (TREE_TYPE (addr)));
- tmp_load = make_ssa_name (tmp_load);
- load = gimple_build_omp_atomic_load (tmp_load, addr,
- OMP_MEMORY_ORDER_RELAXED);
- SSA_NAME_DEF_STMT (tmp_load) = load;
- gsi = gsi_start_bb (new_bb);
- gsi_insert_after (&gsi, load, GSI_NEW_STMT);
-
- e = split_block (new_bb, load);
- new_bb = e->dest;
- gsi = gsi_start_bb (new_bb);
- ref = tmp_load;
- x = fold_build2 (reduc->reduction_code,
- TREE_TYPE (PHI_RESULT (reduc->new_phi)), ref,
- PHI_RESULT (reduc->new_phi));
-
- name = force_gimple_operand_gsi (&gsi, x, true, NULL_TREE, true,
- GSI_CONTINUE_LINKING);
-
- gimple *store = gimple_build_omp_atomic_store (name,
- OMP_MEMORY_ORDER_RELAXED);
- gsi_insert_after (&gsi, store, GSI_NEW_STMT);
- return 1;
-}
-
-/* Create the atomic operation at the join point of the threads.
- REDUCTION_LIST describes the reductions in the LOOP.
- LD_ST_DATA describes the shared data structure where
- shared data is stored in and loaded from. */
-static void
-create_call_for_reduction (class loop *loop,
- reduction_info_table_type *reduction_list,
- struct clsn_data *ld_st_data)
-{
- reduction_list->traverse <class loop *, create_phi_for_local_result> (loop);
- /* Find the fallthru edge from GIMPLE_OMP_CONTINUE. */
- basic_block continue_bb = single_pred (loop->latch);
- ld_st_data->load_bb = FALLTHRU_EDGE (continue_bb)->dest;
- reduction_list
- ->traverse <struct clsn_data *, create_call_for_reduction_1> (ld_st_data);
-}
-
-/* Callback for htab_traverse. Loads the final reduction value at the
- join point of all threads, and inserts it in the right place. */
-
-int
-create_loads_for_reductions (reduction_info **slot, struct clsn_data *clsn_data)
-{
- struct reduction_info *const red = *slot;
- gimple *stmt;
- gimple_stmt_iterator gsi;
- tree type = TREE_TYPE (reduc_stmt_res (red->reduc_stmt));
- tree load_struct;
- tree name;
- tree x;
-
- /* If there's no exit phi, the result of the reduction is unused. */
- if (red->keep_res == NULL)
- return 1;
-
- gsi = gsi_after_labels (clsn_data->load_bb);
- load_struct = build_simple_mem_ref (clsn_data->load);
- load_struct = build3 (COMPONENT_REF, type, load_struct, red->field,
- NULL_TREE);
-
- x = load_struct;
- name = PHI_RESULT (red->keep_res);
- stmt = gimple_build_assign (name, x);
-
- gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
-
- for (gsi = gsi_start_phis (gimple_bb (red->keep_res));
- !gsi_end_p (gsi); gsi_next (&gsi))
- if (gsi_stmt (gsi) == red->keep_res)
- {
- remove_phi_node (&gsi, false);
- return 1;
- }
- gcc_unreachable ();
-}
-
-/* Load the reduction result that was stored in LD_ST_DATA.
- REDUCTION_LIST describes the list of reductions that the
- loads should be generated for. */
-static void
-create_final_loads_for_reduction (reduction_info_table_type *reduction_list,
- struct clsn_data *ld_st_data)
-{
- gimple_stmt_iterator gsi;
- tree t;
- gimple *stmt;
-
- gsi = gsi_after_labels (ld_st_data->load_bb);
- t = build_fold_addr_expr (ld_st_data->store);
- stmt = gimple_build_assign (ld_st_data->load, t);
-
- gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
-
- reduction_list
- ->traverse <struct clsn_data *, create_loads_for_reductions> (ld_st_data);
-
-}
-
-/* Callback for htab_traverse. Store the neutral value for the
- particular reduction's operation, e.g. 0 for PLUS_EXPR,
- 1 for MULT_EXPR, etc. into the reduction field.
- The reduction is specified in SLOT. The store information is
- passed in DATA. */
-
-int
-create_stores_for_reduction (reduction_info **slot, struct clsn_data *clsn_data)
-{
- struct reduction_info *const red = *slot;
- tree t;
- gimple *stmt;
- gimple_stmt_iterator gsi;
- tree type = TREE_TYPE (reduc_stmt_res (red->reduc_stmt));
-
- gsi = gsi_last_bb (clsn_data->store_bb);
- t = build3 (COMPONENT_REF, type, clsn_data->store, red->field, NULL_TREE);
- stmt = gimple_build_assign (t, red->initial_value);
- gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
-
- return 1;
-}
-
-/* Callback for htab_traverse. Creates loads to a field of LOAD in LOAD_BB and
- store to a field of STORE in STORE_BB for the ssa name and its duplicate
- specified in SLOT. */
-
-int
-create_loads_and_stores_for_name (name_to_copy_elt **slot,
- struct clsn_data *clsn_data)
-{
- struct name_to_copy_elt *const elt = *slot;
- tree t;
- gimple *stmt;
- gimple_stmt_iterator gsi;
- tree type = TREE_TYPE (elt->new_name);
- tree load_struct;
-
- gsi = gsi_last_bb (clsn_data->store_bb);
- t = build3 (COMPONENT_REF, type, clsn_data->store, elt->field, NULL_TREE);
- stmt = gimple_build_assign (t, ssa_name (elt->version));
- gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
-
- gsi = gsi_last_bb (clsn_data->load_bb);
- load_struct = build_simple_mem_ref (clsn_data->load);
- t = build3 (COMPONENT_REF, type, load_struct, elt->field, NULL_TREE);
- stmt = gimple_build_assign (elt->new_name, t);
- gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
-
- return 1;
-}
-
-/* Moves all the variables used in LOOP and defined outside of it (including
- the initial values of loop phi nodes, and *PER_THREAD if it is a ssa
- name) to a structure created for this purpose. The code
-
- while (1)
- {
- use (a);
- use (b);
- }
-
- is transformed this way:
-
- bb0:
- old.a = a;
- old.b = b;
-
- bb1:
- a' = new->a;
- b' = new->b;
- while (1)
- {
- use (a');
- use (b');
- }
-
- `old' is stored to *ARG_STRUCT and `new' is stored to NEW_ARG_STRUCT. The
- pointer `new' is intentionally not initialized (the loop will be split to a
- separate function later, and `new' will be initialized from its arguments).
- LD_ST_DATA holds information about the shared data structure used to pass
- information among the threads. It is initialized here, and
- gen_parallel_loop will pass it to create_call_for_reduction that
- needs this information. REDUCTION_LIST describes the reductions
- in LOOP. */
-
-static void
-separate_decls_in_region (edge entry, edge exit,
- reduction_info_table_type *reduction_list,
- tree *arg_struct, tree *new_arg_struct,
- struct clsn_data *ld_st_data)
-
-{
- basic_block bb1 = split_edge (entry);
- basic_block bb0 = single_pred (bb1);
- name_to_copy_table_type name_copies (10);
- int_tree_htab_type decl_copies (10);
- unsigned i;
- tree type, type_name, nvar;
- gimple_stmt_iterator gsi;
- struct clsn_data clsn_data;
- auto_vec<basic_block, 3> body;
- basic_block bb;
- basic_block entry_bb = bb1;
- basic_block exit_bb = exit->dest;
- bool has_debug_stmt = false;
-
- entry = single_succ_edge (entry_bb);
- gather_blocks_in_sese_region (entry_bb, exit_bb, &body);
-
- FOR_EACH_VEC_ELT (body, i, bb)
- {
- if (bb != entry_bb && bb != exit_bb)
- {
- for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
- separate_decls_in_region_stmt (entry, exit, gsi_stmt (gsi),
- &name_copies, &decl_copies);
-
- for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
- {
- gimple *stmt = gsi_stmt (gsi);
-
- if (is_gimple_debug (stmt))
- has_debug_stmt = true;
- else
- separate_decls_in_region_stmt (entry, exit, stmt,
- &name_copies, &decl_copies);
- }
- }
- }
-
- /* Now process debug bind stmts. We must not create decls while
- processing debug stmts, so we defer their processing so as to
- make sure we will have debug info for as many variables as
- possible (all of those that were dealt with in the loop above),
- and discard those for which we know there's nothing we can
- do. */
- if (has_debug_stmt)
- FOR_EACH_VEC_ELT (body, i, bb)
- if (bb != entry_bb && bb != exit_bb)
- {
- for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
- {
- gimple *stmt = gsi_stmt (gsi);
-
- if (is_gimple_debug (stmt))
- {
- if (separate_decls_in_region_debug (stmt, &name_copies,
- &decl_copies))
- {
- gsi_remove (&gsi, true);
- continue;
- }
- }
-
- gsi_next (&gsi);
- }
- }
-
- if (name_copies.is_empty () && reduction_list->is_empty ())
- {
- /* It may happen that there is nothing to copy (if there are only
- loop carried and external variables in the loop). */
- *arg_struct = NULL;
- *new_arg_struct = NULL;
- }
- else
- {
- /* Create the type for the structure to store the ssa names to. */
- type = lang_hooks.types.make_type (RECORD_TYPE);
- type_name = build_decl (UNKNOWN_LOCATION,
- TYPE_DECL, create_tmp_var_name (".paral_data"),
- type);
- TYPE_NAME (type) = type_name;
-
- name_copies.traverse <tree, add_field_for_name> (type);
- if (reduction_list && !reduction_list->is_empty ())
- {
- /* Create the fields for reductions. */
- reduction_list->traverse <tree, add_field_for_reduction> (type);
- }
- layout_type (type);
-
- /* Create the loads and stores. */
- *arg_struct = create_tmp_var (type, ".paral_data_store");
- nvar = create_tmp_var (build_pointer_type (type), ".paral_data_load");
- *new_arg_struct = make_ssa_name (nvar);
-
- ld_st_data->store = *arg_struct;
- ld_st_data->load = *new_arg_struct;
- ld_st_data->store_bb = bb0;
- ld_st_data->load_bb = bb1;
-
- name_copies
- .traverse <struct clsn_data *, create_loads_and_stores_for_name>
- (ld_st_data);
-
- /* Load the calculation from memory (after the join of the threads). */
-
- if (reduction_list && !reduction_list->is_empty ())
- {
- reduction_list
- ->traverse <struct clsn_data *, create_stores_for_reduction>
- (ld_st_data);
- clsn_data.load = make_ssa_name (nvar);
- clsn_data.load_bb = exit->dest;
- clsn_data.store = ld_st_data->store;
- create_final_loads_for_reduction (reduction_list, &clsn_data);
- }
- }
-}
-
-/* Returns true if FN was created to run in parallel. */
-
-bool
-parallelized_function_p (tree fndecl)
-{
- cgraph_node *node = cgraph_node::get (fndecl);
- gcc_assert (node != NULL);
- return node->parallelized_function;
-}
-
-/* Creates and returns an empty function that will receive the body of
- a parallelized loop. */
-
-static tree
-create_loop_fn (location_t loc)
-{
- char buf[100];
- char *tname;
- tree decl, type, name, t;
- struct function *act_cfun = cfun;
- static unsigned loopfn_num;
-
- loc = LOCATION_LOCUS (loc);
- snprintf (buf, 100, "%s.$loopfn", current_function_name ());
- ASM_FORMAT_PRIVATE_NAME (tname, buf, loopfn_num++);
- clean_symbol_name (tname);
- name = get_identifier (tname);
- type = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
-
- decl = build_decl (loc, FUNCTION_DECL, name, type);
- TREE_STATIC (decl) = 1;
- TREE_USED (decl) = 1;
- DECL_ARTIFICIAL (decl) = 1;
- DECL_IGNORED_P (decl) = 0;
- TREE_PUBLIC (decl) = 0;
- DECL_UNINLINABLE (decl) = 1;
- DECL_EXTERNAL (decl) = 0;
- DECL_CONTEXT (decl) = NULL_TREE;
- DECL_INITIAL (decl) = make_node (BLOCK);
- BLOCK_SUPERCONTEXT (DECL_INITIAL (decl)) = decl;
-
- t = build_decl (loc, RESULT_DECL, NULL_TREE, void_type_node);
- DECL_ARTIFICIAL (t) = 1;
- DECL_IGNORED_P (t) = 1;
- DECL_RESULT (decl) = t;
-
- t = build_decl (loc, PARM_DECL, get_identifier (".paral_data_param"),
- ptr_type_node);
- DECL_ARTIFICIAL (t) = 1;
- DECL_ARG_TYPE (t) = ptr_type_node;
- DECL_CONTEXT (t) = decl;
- TREE_USED (t) = 1;
- DECL_ARGUMENTS (decl) = t;
-
- allocate_struct_function (decl, false);
-
- /* The call to allocate_struct_function clobbers CFUN, so we need to restore
- it. */
- set_cfun (act_cfun);
-
- return decl;
-}
-
-/* Replace uses of NAME by VAL in block BB. */
-
-static void
-replace_uses_in_bb_by (tree name, tree val, basic_block bb)
-{
- gimple *use_stmt;
- imm_use_iterator imm_iter;
-
- FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, name)
- {
- if (gimple_bb (use_stmt) != bb)
- continue;
-
- use_operand_p use_p;
- FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
- SET_USE (use_p, val);
- }
-}
-
-/* Do transformation from:
-
- <bb preheader>:
- ...
- goto <bb header>
-
- <bb header>:
- ivtmp_a = PHI <ivtmp_init (preheader), ivtmp_b (latch)>
- sum_a = PHI <sum_init (preheader), sum_b (latch)>
- ...
- use (ivtmp_a)
- ...
- sum_b = sum_a + sum_update
- ...
- if (ivtmp_a < n)
- goto <bb latch>;
- else
- goto <bb exit>;
-
- <bb latch>:
- ivtmp_b = ivtmp_a + 1;
- goto <bb header>
-
- <bb exit>:
- sum_z = PHI <sum_b (cond[1]), ...>
-
- [1] Where <bb cond> is single_pred (bb latch); In the simplest case,
- that's <bb header>.
-
- to:
-
- <bb preheader>:
- ...
- goto <bb newheader>
-
- <bb header>:
- ivtmp_a = PHI <ivtmp_c (latch)>
- sum_a = PHI <sum_c (latch)>
- ...
- use (ivtmp_a)
- ...
- sum_b = sum_a + sum_update
- ...
- goto <bb latch>;
-
- <bb newheader>:
- ivtmp_c = PHI <ivtmp_init (preheader), ivtmp_b (latch)>
- sum_c = PHI <sum_init (preheader), sum_b (latch)>
- if (ivtmp_c < n + 1)
- goto <bb header>;
- else
- goto <bb newexit>;
-
- <bb latch>:
- ivtmp_b = ivtmp_a + 1;
- goto <bb newheader>
-
- <bb newexit>:
- sum_y = PHI <sum_c (newheader)>
-
- <bb exit>:
- sum_z = PHI <sum_y (newexit), ...>
-
-
- In unified diff format:
-
- <bb preheader>:
- ...
-- goto <bb header>
-+ goto <bb newheader>
-
- <bb header>:
-- ivtmp_a = PHI <ivtmp_init (preheader), ivtmp_b (latch)>
-- sum_a = PHI <sum_init (preheader), sum_b (latch)>
-+ ivtmp_a = PHI <ivtmp_c (latch)>
-+ sum_a = PHI <sum_c (latch)>
- ...
- use (ivtmp_a)
- ...
- sum_b = sum_a + sum_update
- ...
-- if (ivtmp_a < n)
-- goto <bb latch>;
-+ goto <bb latch>;
-+
-+ <bb newheader>:
-+ ivtmp_c = PHI <ivtmp_init (preheader), ivtmp_b (latch)>
-+ sum_c = PHI <sum_init (preheader), sum_b (latch)>
-+ if (ivtmp_c < n + 1)
-+ goto <bb header>;
- else
- goto <bb exit>;
-
- <bb latch>:
- ivtmp_b = ivtmp_a + 1;
-- goto <bb header>
-+ goto <bb newheader>
-
-+ <bb newexit>:
-+ sum_y = PHI <sum_c (newheader)>
-
- <bb exit>:
-- sum_z = PHI <sum_b (cond[1]), ...>
-+ sum_z = PHI <sum_y (newexit), ...>
-
- Note: the example does not show any virtual phis, but these are handled more
- or less as reductions.
-
-
- Moves the exit condition of LOOP to the beginning of its header.
- REDUCTION_LIST describes the reductions in LOOP. BOUND is the new loop
- bound. */
-
-static void
-transform_to_exit_first_loop_alt (class loop *loop,
- reduction_info_table_type *reduction_list,
- tree bound)
-{
- basic_block header = loop->header;
- basic_block latch = loop->latch;
- edge exit = single_dom_exit (loop);
- basic_block exit_block = exit->dest;
- gcond *cond_stmt = as_a <gcond *> (last_stmt (exit->src));
- tree control = gimple_cond_lhs (cond_stmt);
- edge e;
-
- /* Rewriting virtuals into loop-closed ssa normal form makes this
- transformation simpler. It also ensures that the virtuals are in
- loop-closed ssa normal from after the transformation, which is required by
- create_parallel_loop. */
- rewrite_virtuals_into_loop_closed_ssa (loop);
-
- /* Create the new_header block. */
- basic_block new_header = split_block_before_cond_jump (exit->src);
- edge edge_at_split = single_pred_edge (new_header);
-
- /* Redirect entry edge to new_header. */
- edge entry = loop_preheader_edge (loop);
- e = redirect_edge_and_branch (entry, new_header);
- gcc_assert (e == entry);
-
- /* Redirect post_inc_edge to new_header. */
- edge post_inc_edge = single_succ_edge (latch);
- e = redirect_edge_and_branch (post_inc_edge, new_header);
- gcc_assert (e == post_inc_edge);
-
- /* Redirect post_cond_edge to header. */
- edge post_cond_edge = single_pred_edge (latch);
- e = redirect_edge_and_branch (post_cond_edge, header);
- gcc_assert (e == post_cond_edge);
-
- /* Redirect edge_at_split to latch. */
- e = redirect_edge_and_branch (edge_at_split, latch);
- gcc_assert (e == edge_at_split);
-
- /* Set the new loop bound. */
- gimple_cond_set_rhs (cond_stmt, bound);
- update_stmt (cond_stmt);
-
- /* Repair the ssa. */
- vec<edge_var_map> *v = redirect_edge_var_map_vector (post_inc_edge);
- edge_var_map *vm;
- gphi_iterator gsi;
- int i;
- for (gsi = gsi_start_phis (header), i = 0;
- !gsi_end_p (gsi) && v->iterate (i, &vm);
- gsi_next (&gsi), i++)
- {
- gphi *phi = gsi.phi ();
- tree res_a = PHI_RESULT (phi);
-
- /* Create new phi. */
- tree res_c = copy_ssa_name (res_a, phi);
- gphi *nphi = create_phi_node (res_c, new_header);
-
- /* Replace ivtmp_a with ivtmp_c in condition 'if (ivtmp_a < n)'. */
- replace_uses_in_bb_by (res_a, res_c, new_header);
-
- /* Replace ivtmp/sum_b with ivtmp/sum_c in header phi. */
- add_phi_arg (phi, res_c, post_cond_edge, UNKNOWN_LOCATION);
-
- /* Replace sum_b with sum_c in exit phi. */
- tree res_b = redirect_edge_var_map_def (vm);
- replace_uses_in_bb_by (res_b, res_c, exit_block);
-
- struct reduction_info *red = reduction_phi (reduction_list, phi);
- gcc_assert (virtual_operand_p (res_a)
- || res_a == control
- || red != NULL);
-
- if (red)
- {
- /* Register the new reduction phi. */
- red->reduc_phi = nphi;
- gimple_set_uid (red->reduc_phi, red->reduc_version);
- }
- }
- gcc_assert (gsi_end_p (gsi) && !v->iterate (i, &vm));
-
- /* Set the preheader argument of the new phis to ivtmp/sum_init. */
- flush_pending_stmts (entry);
-
- /* Set the latch arguments of the new phis to ivtmp/sum_b. */
- flush_pending_stmts (post_inc_edge);
-
-
- basic_block new_exit_block = NULL;
- if (!single_pred_p (exit->dest))
- {
- /* Create a new empty exit block, inbetween the new loop header and the
- old exit block. The function separate_decls_in_region needs this block
- to insert code that is active on loop exit, but not any other path. */
- new_exit_block = split_edge (exit);
- }
-
- /* Insert and register the reduction exit phis. */
- for (gphi_iterator gsi = gsi_start_phis (exit_block);
- !gsi_end_p (gsi);
- gsi_next (&gsi))
- {
- gphi *phi = gsi.phi ();
- gphi *nphi = NULL;
- tree res_z = PHI_RESULT (phi);
- tree res_c;
-
- if (new_exit_block != NULL)
- {
- /* Now that we have a new exit block, duplicate the phi of the old
- exit block in the new exit block to preserve loop-closed ssa. */
- edge succ_new_exit_block = single_succ_edge (new_exit_block);
- edge pred_new_exit_block = single_pred_edge (new_exit_block);
- tree res_y = copy_ssa_name (res_z, phi);
- nphi = create_phi_node (res_y, new_exit_block);
- res_c = PHI_ARG_DEF_FROM_EDGE (phi, succ_new_exit_block);
- add_phi_arg (nphi, res_c, pred_new_exit_block, UNKNOWN_LOCATION);
- add_phi_arg (phi, res_y, succ_new_exit_block, UNKNOWN_LOCATION);
- }
- else
- res_c = PHI_ARG_DEF_FROM_EDGE (phi, exit);
-
- if (virtual_operand_p (res_z))
- continue;
-
- gimple *reduc_phi = SSA_NAME_DEF_STMT (res_c);
- struct reduction_info *red = reduction_phi (reduction_list, reduc_phi);
- if (red != NULL)
- red->keep_res = (nphi != NULL
- ? nphi
- : phi);
- }
-
- /* We're going to cancel the loop at the end of gen_parallel_loop, but until
- then we're still using some fields, so only bother about fields that are
- still used: header and latch.
- The loop has a new header bb, so we update it. The latch bb stays the
- same. */
- loop->header = new_header;
-
- /* Recalculate dominance info. */
- free_dominance_info (CDI_DOMINATORS);
- calculate_dominance_info (CDI_DOMINATORS);
-
- checking_verify_ssa (true, true);
-}
-
-/* Tries to moves the exit condition of LOOP to the beginning of its header
- without duplication of the loop body. NIT is the number of iterations of the
- loop. REDUCTION_LIST describes the reductions in LOOP. Return true if
- transformation is successful. */
-
-static bool
-try_transform_to_exit_first_loop_alt (class loop *loop,
- reduction_info_table_type *reduction_list,
- tree nit)
-{
- /* Check whether the latch contains a single statement. */
- if (!gimple_seq_nondebug_singleton_p (bb_seq (loop->latch)))
- return false;
-
- /* Check whether the latch contains no phis. */
- if (phi_nodes (loop->latch) != NULL)
- return false;
-
- /* Check whether the latch contains the loop iv increment. */
- edge back = single_succ_edge (loop->latch);
- edge exit = single_dom_exit (loop);
- gcond *cond_stmt = as_a <gcond *> (last_stmt (exit->src));
- tree control = gimple_cond_lhs (cond_stmt);
- gphi *phi = as_a <gphi *> (SSA_NAME_DEF_STMT (control));
- tree inc_res = gimple_phi_arg_def (phi, back->dest_idx);
- if (gimple_bb (SSA_NAME_DEF_STMT (inc_res)) != loop->latch)
- return false;
-
- /* Check whether there's no code between the loop condition and the latch. */
- if (!single_pred_p (loop->latch)
- || single_pred (loop->latch) != exit->src)
- return false;
-
- tree alt_bound = NULL_TREE;
- tree nit_type = TREE_TYPE (nit);
-
- /* Figure out whether nit + 1 overflows. */
- if (TREE_CODE (nit) == INTEGER_CST)
- {
- if (!tree_int_cst_equal (nit, TYPE_MAX_VALUE (nit_type)))
- {
- alt_bound = fold_build2_loc (UNKNOWN_LOCATION, PLUS_EXPR, nit_type,
- nit, build_one_cst (nit_type));
-
- gcc_assert (TREE_CODE (alt_bound) == INTEGER_CST);
- transform_to_exit_first_loop_alt (loop, reduction_list, alt_bound);
- return true;
- }
- else
- {
- /* Todo: Figure out if we can trigger this, if it's worth to handle
- optimally, and if we can handle it optimally. */
- return false;
- }
- }
-
- gcc_assert (TREE_CODE (nit) == SSA_NAME);
-
- /* Variable nit is the loop bound as returned by canonicalize_loop_ivs, for an
- iv with base 0 and step 1 that is incremented in the latch, like this:
-
- <bb header>:
- # iv_1 = PHI <0 (preheader), iv_2 (latch)>
- ...
- if (iv_1 < nit)
- goto <bb latch>;
- else
- goto <bb exit>;
-
- <bb latch>:
- iv_2 = iv_1 + 1;
- goto <bb header>;
-
- The range of iv_1 is [0, nit]. The latch edge is taken for
- iv_1 == [0, nit - 1] and the exit edge is taken for iv_1 == nit. So the
- number of latch executions is equal to nit.
-
- The function max_loop_iterations gives us the maximum number of latch
- executions, so it gives us the maximum value of nit. */
- widest_int nit_max;
- if (!max_loop_iterations (loop, &nit_max))
- return false;
-
- /* Check if nit + 1 overflows. */
- widest_int type_max = wi::to_widest (TYPE_MAX_VALUE (nit_type));
- if (nit_max >= type_max)
- return false;
-
- gimple *def = SSA_NAME_DEF_STMT (nit);
-
- /* Try to find nit + 1, in the form of n in an assignment nit = n - 1. */
- if (def
- && is_gimple_assign (def)
- && gimple_assign_rhs_code (def) == PLUS_EXPR)
- {
- tree op1 = gimple_assign_rhs1 (def);
- tree op2 = gimple_assign_rhs2 (def);
- if (integer_minus_onep (op1))
- alt_bound = op2;
- else if (integer_minus_onep (op2))
- alt_bound = op1;
- }
-
- /* If not found, insert nit + 1. */
- if (alt_bound == NULL_TREE)
- {
- alt_bound = fold_build2 (PLUS_EXPR, nit_type, nit,
- build_int_cst_type (nit_type, 1));
-
- gimple_stmt_iterator gsi = gsi_last_bb (loop_preheader_edge (loop)->src);
-
- alt_bound
- = force_gimple_operand_gsi (&gsi, alt_bound, true, NULL_TREE, false,
- GSI_CONTINUE_LINKING);
- }
-
- transform_to_exit_first_loop_alt (loop, reduction_list, alt_bound);
- return true;
-}
-
-/* Moves the exit condition of LOOP to the beginning of its header. NIT is the
- number of iterations of the loop. REDUCTION_LIST describes the reductions in
- LOOP. */
-
-static void
-transform_to_exit_first_loop (class loop *loop,
- reduction_info_table_type *reduction_list,
- tree nit)
-{
- basic_block *bbs, *nbbs, ex_bb, orig_header;
- unsigned n;
- bool ok;
- edge exit = single_dom_exit (loop), hpred;
- tree control, control_name, res, t;
- gphi *phi, *nphi;
- gassign *stmt;
- gcond *cond_stmt, *cond_nit;
- tree nit_1;
-
- split_block_after_labels (loop->header);
- orig_header = single_succ (loop->header);
- hpred = single_succ_edge (loop->header);
-
- cond_stmt = as_a <gcond *> (last_stmt (exit->src));
- control = gimple_cond_lhs (cond_stmt);
- gcc_assert (gimple_cond_rhs (cond_stmt) == nit);
-
- /* Make sure that we have phi nodes on exit for all loop header phis
- (create_parallel_loop requires that). */
- for (gphi_iterator gsi = gsi_start_phis (loop->header);
- !gsi_end_p (gsi);
- gsi_next (&gsi))
- {
- phi = gsi.phi ();
- res = PHI_RESULT (phi);
- t = copy_ssa_name (res, phi);
- SET_PHI_RESULT (phi, t);
- nphi = create_phi_node (res, orig_header);
- add_phi_arg (nphi, t, hpred, UNKNOWN_LOCATION);
-
- if (res == control)
- {
- gimple_cond_set_lhs (cond_stmt, t);
- update_stmt (cond_stmt);
- control = t;
- }
- }
-
- bbs = get_loop_body_in_dom_order (loop);
-
- for (n = 0; bbs[n] != exit->src; n++)
- continue;
- nbbs = XNEWVEC (basic_block, n);
- ok = gimple_duplicate_sese_tail (single_succ_edge (loop->header), exit,
- bbs + 1, n, nbbs);
- gcc_assert (ok);
- free (bbs);
- ex_bb = nbbs[0];
- free (nbbs);
-
- /* Other than reductions, the only gimple reg that should be copied
- out of the loop is the control variable. */
- exit = single_dom_exit (loop);
- control_name = NULL_TREE;
- for (gphi_iterator gsi = gsi_start_phis (ex_bb);
- !gsi_end_p (gsi); )
- {
- phi = gsi.phi ();
- res = PHI_RESULT (phi);
- if (virtual_operand_p (res))
- {
- gsi_next (&gsi);
- continue;
- }
-
- /* Check if it is a part of reduction. If it is,
- keep the phi at the reduction's keep_res field. The
- PHI_RESULT of this phi is the resulting value of the reduction
- variable when exiting the loop. */
-
- if (!reduction_list->is_empty ())
- {
- struct reduction_info *red;
-
- tree val = PHI_ARG_DEF_FROM_EDGE (phi, exit);
- red = reduction_phi (reduction_list, SSA_NAME_DEF_STMT (val));
- if (red)
- {
- red->keep_res = phi;
- gsi_next (&gsi);
- continue;
- }
- }
- gcc_assert (control_name == NULL_TREE
- && SSA_NAME_VAR (res) == SSA_NAME_VAR (control));
- control_name = res;
- remove_phi_node (&gsi, false);
- }
- gcc_assert (control_name != NULL_TREE);
-
- /* Initialize the control variable to number of iterations
- according to the rhs of the exit condition. */
- gimple_stmt_iterator gsi = gsi_after_labels (ex_bb);
- cond_nit = as_a <gcond *> (last_stmt (exit->src));
- nit_1 = gimple_cond_rhs (cond_nit);
- nit_1 = force_gimple_operand_gsi (&gsi,
- fold_convert (TREE_TYPE (control_name), nit_1),
- false, NULL_TREE, false, GSI_SAME_STMT);
- stmt = gimple_build_assign (control_name, nit_1);
- gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
-}
-
-/* Create the parallel constructs for LOOP as described in gen_parallel_loop.
- LOOP_FN and DATA are the arguments of GIMPLE_OMP_PARALLEL.
- NEW_DATA is the variable that should be initialized from the argument
- of LOOP_FN. N_THREADS is the requested number of threads, which can be 0 if
- that number is to be determined later. */
-
-static void
-create_parallel_loop (class loop *loop, tree loop_fn, tree data,
- tree new_data, unsigned n_threads, location_t loc,
- bool oacc_kernels_p)
-{
- gimple_stmt_iterator gsi;
- basic_block for_bb, ex_bb, continue_bb;
- tree t, param;
- gomp_parallel *omp_par_stmt;
- gimple *omp_return_stmt1, *omp_return_stmt2;
- gimple *phi;
- gcond *cond_stmt;
- gomp_for *for_stmt;
- gomp_continue *omp_cont_stmt;
- tree cvar, cvar_init, initvar, cvar_next, cvar_base, type;
- edge exit, nexit, guard, end, e;
-
- if (oacc_kernels_p)
- {
- gcc_checking_assert (lookup_attribute ("oacc kernels",
- DECL_ATTRIBUTES (cfun->decl)));
- /* Indicate to later processing that this is a parallelized OpenACC
- kernels construct. */
- DECL_ATTRIBUTES (cfun->decl)
- = tree_cons (get_identifier ("oacc kernels parallelized"),
- NULL_TREE, DECL_ATTRIBUTES (cfun->decl));
- }
- else
- {
- /* Prepare the GIMPLE_OMP_PARALLEL statement. */
-
- basic_block bb = loop_preheader_edge (loop)->src;
- basic_block paral_bb = single_pred (bb);
- gsi = gsi_last_bb (paral_bb);
-
- gcc_checking_assert (n_threads != 0);
- t = build_omp_clause (loc, OMP_CLAUSE_NUM_THREADS);
- OMP_CLAUSE_NUM_THREADS_EXPR (t)
- = build_int_cst (integer_type_node, n_threads);
- omp_par_stmt = gimple_build_omp_parallel (NULL, t, loop_fn, data);
- gimple_set_location (omp_par_stmt, loc);
-
- gsi_insert_after (&gsi, omp_par_stmt, GSI_NEW_STMT);
-
- /* Initialize NEW_DATA. */
- if (data)
- {
- gassign *assign_stmt;
-
- gsi = gsi_after_labels (bb);
-
- param = make_ssa_name (DECL_ARGUMENTS (loop_fn));
- assign_stmt = gimple_build_assign (param, build_fold_addr_expr (data));
- gsi_insert_before (&gsi, assign_stmt, GSI_SAME_STMT);
-
- assign_stmt = gimple_build_assign (new_data,
- fold_convert (TREE_TYPE (new_data), param));
- gsi_insert_before (&gsi, assign_stmt, GSI_SAME_STMT);
- }
-
- /* Emit GIMPLE_OMP_RETURN for GIMPLE_OMP_PARALLEL. */
- bb = split_loop_exit_edge (single_dom_exit (loop));
- gsi = gsi_last_bb (bb);
- omp_return_stmt1 = gimple_build_omp_return (false);
- gimple_set_location (omp_return_stmt1, loc);
- gsi_insert_after (&gsi, omp_return_stmt1, GSI_NEW_STMT);
- }
-
- /* Extract data for GIMPLE_OMP_FOR. */
- gcc_assert (loop->header == single_dom_exit (loop)->src);
- cond_stmt = as_a <gcond *> (last_stmt (loop->header));
-
- cvar = gimple_cond_lhs (cond_stmt);
- cvar_base = SSA_NAME_VAR (cvar);
- phi = SSA_NAME_DEF_STMT (cvar);
- cvar_init = PHI_ARG_DEF_FROM_EDGE (phi, loop_preheader_edge (loop));
- initvar = copy_ssa_name (cvar);
- SET_USE (PHI_ARG_DEF_PTR_FROM_EDGE (phi, loop_preheader_edge (loop)),
- initvar);
- cvar_next = PHI_ARG_DEF_FROM_EDGE (phi, loop_latch_edge (loop));
-
- gsi = gsi_last_nondebug_bb (loop->latch);
- gcc_assert (gsi_stmt (gsi) == SSA_NAME_DEF_STMT (cvar_next));
- gsi_remove (&gsi, true);
-
- /* Prepare cfg. */
- for_bb = split_edge (loop_preheader_edge (loop));
- ex_bb = split_loop_exit_edge (single_dom_exit (loop));
- extract_true_false_edges_from_block (loop->header, &nexit, &exit);
- gcc_assert (exit == single_dom_exit (loop));
-
- guard = make_edge (for_bb, ex_bb, 0);
- /* FIXME: What is the probability? */
- guard->probability = profile_probability::guessed_never ();
- /* Split the latch edge, so LOOPS_HAVE_SIMPLE_LATCHES is still valid. */
- loop->latch = split_edge (single_succ_edge (loop->latch));
- single_pred_edge (loop->latch)->flags = 0;
- end = make_single_succ_edge (single_pred (loop->latch), ex_bb, EDGE_FALLTHRU);
- rescan_loop_exit (end, true, false);
-
- for (gphi_iterator gpi = gsi_start_phis (ex_bb);
- !gsi_end_p (gpi); gsi_next (&gpi))
- {
- location_t locus;
- gphi *phi = gpi.phi ();
- tree def = PHI_ARG_DEF_FROM_EDGE (phi, exit);
- gimple *def_stmt = SSA_NAME_DEF_STMT (def);
-
- /* If the exit phi is not connected to a header phi in the same loop, this
- value is not modified in the loop, and we're done with this phi. */
- if (!(gimple_code (def_stmt) == GIMPLE_PHI
- && gimple_bb (def_stmt) == loop->header))
- {
- locus = gimple_phi_arg_location_from_edge (phi, exit);
- add_phi_arg (phi, def, guard, locus);
- add_phi_arg (phi, def, end, locus);
- continue;
- }
-
- gphi *stmt = as_a <gphi *> (def_stmt);
- def = PHI_ARG_DEF_FROM_EDGE (stmt, loop_preheader_edge (loop));
- locus = gimple_phi_arg_location_from_edge (stmt,
- loop_preheader_edge (loop));
- add_phi_arg (phi, def, guard, locus);
-
- def = PHI_ARG_DEF_FROM_EDGE (stmt, loop_latch_edge (loop));
- locus = gimple_phi_arg_location_from_edge (stmt, loop_latch_edge (loop));
- add_phi_arg (phi, def, end, locus);
- }
- e = redirect_edge_and_branch (exit, nexit->dest);
- PENDING_STMT (e) = NULL;
-
- /* Emit GIMPLE_OMP_FOR. */
- if (oacc_kernels_p)
- /* Parallelized OpenACC kernels constructs use gang parallelism. See also
- omp-offload.c:execute_oacc_loop_designation. */
- t = build_omp_clause (loc, OMP_CLAUSE_GANG);
- else
- {
- t = build_omp_clause (loc, OMP_CLAUSE_SCHEDULE);
- int chunk_size = param_parloops_chunk_size;
- switch (param_parloops_schedule)
- {
- case PARLOOPS_SCHEDULE_STATIC:
- OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_STATIC;
- break;
- case PARLOOPS_SCHEDULE_DYNAMIC:
- OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_DYNAMIC;
- break;
- case PARLOOPS_SCHEDULE_GUIDED:
- OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_GUIDED;
- break;
- case PARLOOPS_SCHEDULE_AUTO:
- OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_AUTO;
- chunk_size = 0;
- break;
- case PARLOOPS_SCHEDULE_RUNTIME:
- OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_RUNTIME;
- chunk_size = 0;
- break;
- default:
- gcc_unreachable ();
- }
- if (chunk_size != 0)
- OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (t)
- = build_int_cst (integer_type_node, chunk_size);
- }
-
- for_stmt = gimple_build_omp_for (NULL,
- (oacc_kernels_p
- ? GF_OMP_FOR_KIND_OACC_LOOP
- : GF_OMP_FOR_KIND_FOR),
- t, 1, NULL);
-
- gimple_cond_set_lhs (cond_stmt, cvar_base);
- type = TREE_TYPE (cvar);
- gimple_set_location (for_stmt, loc);
- gimple_omp_for_set_index (for_stmt, 0, initvar);
- gimple_omp_for_set_initial (for_stmt, 0, cvar_init);
- gimple_omp_for_set_final (for_stmt, 0, gimple_cond_rhs (cond_stmt));
- gimple_omp_for_set_cond (for_stmt, 0, gimple_cond_code (cond_stmt));
- gimple_omp_for_set_incr (for_stmt, 0, build2 (PLUS_EXPR, type,
- cvar_base,
- build_int_cst (type, 1)));
-
- gsi = gsi_last_bb (for_bb);
- gsi_insert_after (&gsi, for_stmt, GSI_NEW_STMT);
- SSA_NAME_DEF_STMT (initvar) = for_stmt;
-
- /* Emit GIMPLE_OMP_CONTINUE. */
- continue_bb = single_pred (loop->latch);
- gsi = gsi_last_bb (continue_bb);
- omp_cont_stmt = gimple_build_omp_continue (cvar_next, cvar);
- gimple_set_location (omp_cont_stmt, loc);
- gsi_insert_after (&gsi, omp_cont_stmt, GSI_NEW_STMT);
- SSA_NAME_DEF_STMT (cvar_next) = omp_cont_stmt;
-
- /* Emit GIMPLE_OMP_RETURN for GIMPLE_OMP_FOR. */
- gsi = gsi_last_bb (ex_bb);
- omp_return_stmt2 = gimple_build_omp_return (true);
- gimple_set_location (omp_return_stmt2, loc);
- gsi_insert_after (&gsi, omp_return_stmt2, GSI_NEW_STMT);
-
- /* After the above dom info is hosed. Re-compute it. */
- free_dominance_info (CDI_DOMINATORS);
- calculate_dominance_info (CDI_DOMINATORS);
-}
-
-/* Return number of phis in bb. If COUNT_VIRTUAL_P is false, don't count the
- virtual phi. */
-
-static unsigned int
-num_phis (basic_block bb, bool count_virtual_p)
-{
- unsigned int nr_phis = 0;
- gphi_iterator gsi;
- for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
- {
- if (!count_virtual_p && virtual_operand_p (PHI_RESULT (gsi.phi ())))
- continue;
-
- nr_phis++;
- }
-
- return nr_phis;
-}
-
-/* Generates code to execute the iterations of LOOP in N_THREADS
- threads in parallel, which can be 0 if that number is to be determined
- later.
-
- NITER describes number of iterations of LOOP.
- REDUCTION_LIST describes the reductions existent in the LOOP. */
-
-static void
-gen_parallel_loop (class loop *loop,
- reduction_info_table_type *reduction_list,
- unsigned n_threads, class tree_niter_desc *niter,
- bool oacc_kernels_p)
-{
- tree many_iterations_cond, type, nit;
- tree arg_struct, new_arg_struct;
- gimple_seq stmts;
- edge entry, exit;
- struct clsn_data clsn_data;
- location_t loc;
- gimple *cond_stmt;
- unsigned int m_p_thread=2;
-
- /* From
-
- ---------------------------------------------------------------------
- loop
- {
- IV = phi (INIT, IV + STEP)
- BODY1;
- if (COND)
- break;
- BODY2;
- }
- ---------------------------------------------------------------------
-
- with # of iterations NITER (possibly with MAY_BE_ZERO assumption),
- we generate the following code:
-
- ---------------------------------------------------------------------
-
- if (MAY_BE_ZERO
- || NITER < MIN_PER_THREAD * N_THREADS)
- goto original;
-
- BODY1;
- store all local loop-invariant variables used in body of the loop to DATA.
- GIMPLE_OMP_PARALLEL (OMP_CLAUSE_NUM_THREADS (N_THREADS), LOOPFN, DATA);
- load the variables from DATA.
- GIMPLE_OMP_FOR (IV = INIT; COND; IV += STEP) (OMP_CLAUSE_SCHEDULE (static))
- BODY2;
- BODY1;
- GIMPLE_OMP_CONTINUE;
- GIMPLE_OMP_RETURN -- GIMPLE_OMP_FOR
- GIMPLE_OMP_RETURN -- GIMPLE_OMP_PARALLEL
- goto end;
-
- original:
- loop
- {
- IV = phi (INIT, IV + STEP)
- BODY1;
- if (COND)
- break;
- BODY2;
- }
-
- end:
-
- */
-
- /* Create two versions of the loop -- in the old one, we know that the
- number of iterations is large enough, and we will transform it into the
- loop that will be split to loop_fn, the new one will be used for the
- remaining iterations. */
-
- /* We should compute a better number-of-iterations value for outer loops.
- That is, if we have
-
- for (i = 0; i < n; ++i)
- for (j = 0; j < m; ++j)
- ...
-
- we should compute nit = n * m, not nit = n.
- Also may_be_zero handling would need to be adjusted. */
-
- type = TREE_TYPE (niter->niter);
- nit = force_gimple_operand (unshare_expr (niter->niter), &stmts, true,
- NULL_TREE);
- if (stmts)
- gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
-
- if (!oacc_kernels_p)
- {
- if (loop->inner)
- m_p_thread=2;
- else
- m_p_thread=MIN_PER_THREAD;
-
- gcc_checking_assert (n_threads != 0);
- many_iterations_cond =
- fold_build2 (GE_EXPR, boolean_type_node,
- nit, build_int_cst (type, m_p_thread * n_threads - 1));
-
- many_iterations_cond
- = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
- invert_truthvalue (unshare_expr (niter->may_be_zero)),
- many_iterations_cond);
- many_iterations_cond
- = force_gimple_operand (many_iterations_cond, &stmts, false, NULL_TREE);
- if (stmts)
- gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
- if (!is_gimple_condexpr (many_iterations_cond))
- {
- many_iterations_cond
- = force_gimple_operand (many_iterations_cond, &stmts,
- true, NULL_TREE);
- if (stmts)
- gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop),
- stmts);
- }
-
- initialize_original_copy_tables ();
-
- /* We assume that the loop usually iterates a lot. */
- loop_version (loop, many_iterations_cond, NULL,
- profile_probability::likely (),
- profile_probability::unlikely (),
- profile_probability::likely (),
- profile_probability::unlikely (), true);
- update_ssa (TODO_update_ssa);
- free_original_copy_tables ();
- }
-
- /* Base all the induction variables in LOOP on a single control one. */
- canonicalize_loop_ivs (loop, &nit, true);
- if (num_phis (loop->header, false) != reduction_list->elements () + 1)
- {
- /* The call to canonicalize_loop_ivs above failed to "base all the
- induction variables in LOOP on a single control one". Do damage
- control. */
- basic_block preheader = loop_preheader_edge (loop)->src;
- basic_block cond_bb = single_pred (preheader);
- gcond *cond = as_a <gcond *> (gsi_stmt (gsi_last_bb (cond_bb)));
- gimple_cond_make_true (cond);
- update_stmt (cond);
- /* We've gotten rid of the duplicate loop created by loop_version, but
- we can't undo whatever canonicalize_loop_ivs has done.
- TODO: Fix this properly by ensuring that the call to
- canonicalize_loop_ivs succeeds. */
- if (dump_file
- && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, "canonicalize_loop_ivs failed for loop %d,"
- " aborting transformation\n", loop->num);
- return;
- }
-
- /* Ensure that the exit condition is the first statement in the loop.
- The common case is that latch of the loop is empty (apart from the
- increment) and immediately follows the loop exit test. Attempt to move the
- entry of the loop directly before the exit check and increase the number of
- iterations of the loop by one. */
- if (try_transform_to_exit_first_loop_alt (loop, reduction_list, nit))
- {
- if (dump_file
- && (dump_flags & TDF_DETAILS))
- fprintf (dump_file,
- "alternative exit-first loop transform succeeded"
- " for loop %d\n", loop->num);
- }
- else
- {
- if (oacc_kernels_p)
- n_threads = 1;
-
- /* Fall back on the method that handles more cases, but duplicates the
- loop body: move the exit condition of LOOP to the beginning of its
- header, and duplicate the part of the last iteration that gets disabled
- to the exit of the loop. */
- transform_to_exit_first_loop (loop, reduction_list, nit);
- }
-
- /* Generate initializations for reductions. */
- if (!reduction_list->is_empty ())
- reduction_list->traverse <class loop *, initialize_reductions> (loop);
-
- /* Eliminate the references to local variables from the loop. */
- gcc_assert (single_exit (loop));
- entry = loop_preheader_edge (loop);
- exit = single_dom_exit (loop);
-
- /* This rewrites the body in terms of new variables. This has already
- been done for oacc_kernels_p in pass_lower_omp/lower_omp (). */
- if (!oacc_kernels_p)
- {
- eliminate_local_variables (entry, exit);
- /* In the old loop, move all variables non-local to the loop to a
- structure and back, and create separate decls for the variables used in
- loop. */
- separate_decls_in_region (entry, exit, reduction_list, &arg_struct,
- &new_arg_struct, &clsn_data);
- }
- else
- {
- arg_struct = NULL_TREE;
- new_arg_struct = NULL_TREE;
- clsn_data.load = NULL_TREE;
- clsn_data.load_bb = exit->dest;
- clsn_data.store = NULL_TREE;
- clsn_data.store_bb = NULL;
- }
-
- /* Create the parallel constructs. */
- loc = UNKNOWN_LOCATION;
- cond_stmt = last_stmt (loop->header);
- if (cond_stmt)
- loc = gimple_location (cond_stmt);
- create_parallel_loop (loop, create_loop_fn (loc), arg_struct, new_arg_struct,
- n_threads, loc, oacc_kernels_p);
- if (!reduction_list->is_empty ())
- create_call_for_reduction (loop, reduction_list, &clsn_data);
-
- scev_reset ();
-
- /* Free loop bound estimations that could contain references to
- removed statements. */
- free_numbers_of_iterations_estimates (cfun);
-}
-
-/* Returns true when LOOP contains vector phi nodes. */
-
-static bool
-loop_has_vector_phi_nodes (class loop *loop ATTRIBUTE_UNUSED)
-{
- unsigned i;
- basic_block *bbs = get_loop_body_in_dom_order (loop);
- gphi_iterator gsi;
- bool res = true;
-
- for (i = 0; i < loop->num_nodes; i++)
- for (gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi))
- if (TREE_CODE (TREE_TYPE (PHI_RESULT (gsi.phi ()))) == VECTOR_TYPE)
- goto end;
-
- res = false;
- end:
- free (bbs);
- return res;
-}
-
-/* Create a reduction_info struct, initialize it with REDUC_STMT
- and PHI, insert it to the REDUCTION_LIST. */
-
-static void
-build_new_reduction (reduction_info_table_type *reduction_list,
- gimple *reduc_stmt, gphi *phi)
-{
- reduction_info **slot;
- struct reduction_info *new_reduction;
- enum tree_code reduction_code;
-
- gcc_assert (reduc_stmt);
-
- if (gimple_code (reduc_stmt) == GIMPLE_PHI)
- {
- tree op1 = PHI_ARG_DEF (reduc_stmt, 0);
- gimple *def1 = SSA_NAME_DEF_STMT (op1);
- reduction_code = gimple_assign_rhs_code (def1);
- }
- else
- reduction_code = gimple_assign_rhs_code (reduc_stmt);
- /* Check for OpenMP supported reduction. */
- switch (reduction_code)
- {
- case PLUS_EXPR:
- case MULT_EXPR:
- case MAX_EXPR:
- case MIN_EXPR:
- case BIT_IOR_EXPR:
- case BIT_XOR_EXPR:
- case BIT_AND_EXPR:
- case TRUTH_OR_EXPR:
- case TRUTH_XOR_EXPR:
- case TRUTH_AND_EXPR:
- break;
- default:
- return;
- }
-
- if (dump_file && (dump_flags & TDF_DETAILS))
- {
- fprintf (dump_file,
- "Detected reduction. reduction stmt is:\n");
- print_gimple_stmt (dump_file, reduc_stmt, 0);
- fprintf (dump_file, "\n");
- }
-
- new_reduction = XCNEW (struct reduction_info);
-
- new_reduction->reduc_stmt = reduc_stmt;
- new_reduction->reduc_phi = phi;
- new_reduction->reduc_version = SSA_NAME_VERSION (gimple_phi_result (phi));
- new_reduction->reduction_code = reduction_code;
- slot = reduction_list->find_slot (new_reduction, INSERT);
- *slot = new_reduction;
-}
-
-/* Callback for htab_traverse. Sets gimple_uid of reduc_phi stmts. */
-
-int
-set_reduc_phi_uids (reduction_info **slot, void *data ATTRIBUTE_UNUSED)
-{
- struct reduction_info *const red = *slot;
- gimple_set_uid (red->reduc_phi, red->reduc_version);
- return 1;
-}
-
-/* Return true if the type of reduction performed by STMT_INFO is suitable
- for this pass. */
-
-static bool
-valid_reduction_p (stmt_vec_info stmt_info)
-{
- /* Parallelization would reassociate the operation, which isn't
- allowed for in-order reductions. */
- vect_reduction_type reduc_type = STMT_VINFO_REDUC_TYPE (stmt_info);
- return reduc_type != FOLD_LEFT_REDUCTION;
-}
-
-/* Detect all reductions in the LOOP, insert them into REDUCTION_LIST. */
-
-static void
-gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list)
-{
- gphi_iterator gsi;
- loop_vec_info simple_loop_info;
- auto_vec<gphi *, 4> double_reduc_phis;
- auto_vec<gimple *, 4> double_reduc_stmts;
-
- vec_info_shared shared;
- vect_loop_form_info info;
- if (!vect_analyze_loop_form (loop, &info))
- goto gather_done;
-
- simple_loop_info = vect_create_loop_vinfo (loop, &shared, &info);
- for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
- {
- gphi *phi = gsi.phi ();
- affine_iv iv;
- tree res = PHI_RESULT (phi);
- bool double_reduc;
-
- if (virtual_operand_p (res))
- continue;
-
- if (simple_iv (loop, loop, res, &iv, true))
- continue;
-
- stmt_vec_info reduc_stmt_info
- = parloops_force_simple_reduction (simple_loop_info,
- simple_loop_info->lookup_stmt (phi),
- &double_reduc, true);
- if (!reduc_stmt_info || !valid_reduction_p (reduc_stmt_info))
- continue;
-
- if (double_reduc)
- {
- if (loop->inner->inner != NULL)
- continue;
-
- double_reduc_phis.safe_push (phi);
- double_reduc_stmts.safe_push (reduc_stmt_info->stmt);
- continue;
- }
-
- build_new_reduction (reduction_list, reduc_stmt_info->stmt, phi);
- }
- delete simple_loop_info;
-
- if (!double_reduc_phis.is_empty ())
- {
- vec_info_shared shared;
- vect_loop_form_info info;
- if (vect_analyze_loop_form (loop->inner, &info))
- {
- simple_loop_info
- = vect_create_loop_vinfo (loop->inner, &shared, &info);
- gphi *phi;
- unsigned int i;
-
- FOR_EACH_VEC_ELT (double_reduc_phis, i, phi)
- {
- affine_iv iv;
- tree res = PHI_RESULT (phi);
- bool double_reduc;
-
- use_operand_p use_p;
- gimple *inner_stmt;
- bool single_use_p = single_imm_use (res, &use_p, &inner_stmt);
- gcc_assert (single_use_p);
- if (gimple_code (inner_stmt) != GIMPLE_PHI)
- continue;
- gphi *inner_phi = as_a <gphi *> (inner_stmt);
- if (simple_iv (loop->inner, loop->inner, PHI_RESULT (inner_phi),
- &iv, true))
- continue;
-
- stmt_vec_info inner_phi_info
- = simple_loop_info->lookup_stmt (inner_phi);
- stmt_vec_info inner_reduc_stmt_info
- = parloops_force_simple_reduction (simple_loop_info,
- inner_phi_info,
- &double_reduc, true);
- gcc_assert (!double_reduc);
- if (!inner_reduc_stmt_info
- || !valid_reduction_p (inner_reduc_stmt_info))
- continue;
-
- build_new_reduction (reduction_list, double_reduc_stmts[i], phi);
- }
- delete simple_loop_info;
- }
- }
-
- gather_done:
- if (reduction_list->is_empty ())
- return;
-
- /* As gimple_uid is used by the vectorizer in between vect_analyze_loop_form
- and delete simple_loop_info, we can set gimple_uid of reduc_phi stmts only
- now. */
- basic_block bb;
- FOR_EACH_BB_FN (bb, cfun)
- for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
- gimple_set_uid (gsi_stmt (gsi), (unsigned int)-1);
- reduction_list->traverse <void *, set_reduc_phi_uids> (NULL);
-}
-
-/* Try to initialize NITER for code generation part. */
-
-static bool
-try_get_loop_niter (loop_p loop, class tree_niter_desc *niter)
-{
- edge exit = single_dom_exit (loop);
-
- gcc_assert (exit);
-
- /* We need to know # of iterations, and there should be no uses of values
- defined inside loop outside of it, unless the values are invariants of
- the loop. */
- if (!number_of_iterations_exit (loop, exit, niter, false))
- {
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, " FAILED: number of iterations not known\n");
- return false;
- }
-
- return true;
-}
-
-/* Return the default def of the first function argument. */
-
-static tree
-get_omp_data_i_param (void)
-{
- tree decl = DECL_ARGUMENTS (cfun->decl);
- gcc_assert (DECL_CHAIN (decl) == NULL_TREE);
- return ssa_default_def (cfun, decl);
-}
-
-/* For PHI in loop header of LOOP, look for pattern:
-
- <bb preheader>
- .omp_data_i = &.omp_data_arr;
- addr = .omp_data_i->sum;
- sum_a = *addr;
-
- <bb header>:
- sum_b = PHI <sum_a (preheader), sum_c (latch)>
-
- and return addr. Otherwise, return NULL_TREE. */
-
-static tree
-find_reduc_addr (class loop *loop, gphi *phi)
-{
- edge e = loop_preheader_edge (loop);
- tree arg = PHI_ARG_DEF_FROM_EDGE (phi, e);
- gimple *stmt = SSA_NAME_DEF_STMT (arg);
- if (!gimple_assign_single_p (stmt))
- return NULL_TREE;
- tree memref = gimple_assign_rhs1 (stmt);
- if (TREE_CODE (memref) != MEM_REF)
- return NULL_TREE;
- tree addr = TREE_OPERAND (memref, 0);
-
- gimple *stmt2 = SSA_NAME_DEF_STMT (addr);
- if (!gimple_assign_single_p (stmt2))
- return NULL_TREE;
- tree compref = gimple_assign_rhs1 (stmt2);
- if (TREE_CODE (compref) != COMPONENT_REF)
- return NULL_TREE;
- tree addr2 = TREE_OPERAND (compref, 0);
- if (TREE_CODE (addr2) != MEM_REF)
- return NULL_TREE;
- addr2 = TREE_OPERAND (addr2, 0);
- if (TREE_CODE (addr2) != SSA_NAME
- || addr2 != get_omp_data_i_param ())
- return NULL_TREE;
-
- return addr;
-}
-
-/* Try to initialize REDUCTION_LIST for code generation part.
- REDUCTION_LIST describes the reductions. */
-
-static bool
-try_create_reduction_list (loop_p loop,
- reduction_info_table_type *reduction_list,
- bool oacc_kernels_p)
-{
- edge exit = single_dom_exit (loop);
- gphi_iterator gsi;
-
- gcc_assert (exit);
-
- /* Try to get rid of exit phis. */
- final_value_replacement_loop (loop);
-
- gather_scalar_reductions (loop, reduction_list);
-
-
- for (gsi = gsi_start_phis (exit->dest); !gsi_end_p (gsi); gsi_next (&gsi))
- {
- gphi *phi = gsi.phi ();
- struct reduction_info *red;
- imm_use_iterator imm_iter;
- use_operand_p use_p;
- gimple *reduc_phi;
- tree val = PHI_ARG_DEF_FROM_EDGE (phi, exit);
-
- if (!virtual_operand_p (val))
- {
- if (TREE_CODE (val) != SSA_NAME)
- {
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file,
- " FAILED: exit PHI argument invariant.\n");
- return false;
- }
-
- if (dump_file && (dump_flags & TDF_DETAILS))
- {
- fprintf (dump_file, "phi is ");
- print_gimple_stmt (dump_file, phi, 0);
- fprintf (dump_file, "arg of phi to exit: value ");
- print_generic_expr (dump_file, val);
- fprintf (dump_file, " used outside loop\n");
- fprintf (dump_file,
- " checking if it is part of reduction pattern:\n");
- }
- if (reduction_list->is_empty ())
- {
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file,
- " FAILED: it is not a part of reduction.\n");
- return false;
- }
- reduc_phi = NULL;
- FOR_EACH_IMM_USE_FAST (use_p, imm_iter, val)
- {
- if (!gimple_debug_bind_p (USE_STMT (use_p))
- && flow_bb_inside_loop_p (loop, gimple_bb (USE_STMT (use_p))))
- {
- reduc_phi = USE_STMT (use_p);
- break;
- }
- }
- red = reduction_phi (reduction_list, reduc_phi);
- if (red == NULL)
- {
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file,
- " FAILED: it is not a part of reduction.\n");
- return false;
- }
- if (red->keep_res != NULL)
- {
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file,
- " FAILED: reduction has multiple exit phis.\n");
- return false;
- }
- red->keep_res = phi;
- if (dump_file && (dump_flags & TDF_DETAILS))
- {
- fprintf (dump_file, "reduction phi is ");
- print_gimple_stmt (dump_file, red->reduc_phi, 0);
- fprintf (dump_file, "reduction stmt is ");
- print_gimple_stmt (dump_file, red->reduc_stmt, 0);
- }
- }
- }
-
- /* The iterations of the loop may communicate only through bivs whose
- iteration space can be distributed efficiently. */
- for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
- {
- gphi *phi = gsi.phi ();
- tree def = PHI_RESULT (phi);
- affine_iv iv;
-
- if (!virtual_operand_p (def) && !simple_iv (loop, loop, def, &iv, true))
- {
- struct reduction_info *red;
-
- red = reduction_phi (reduction_list, phi);
- if (red == NULL)
- {
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file,
- " FAILED: scalar dependency between iterations\n");
- return false;
- }
- }
- }
-
- if (oacc_kernels_p)
- {
- for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi);
- gsi_next (&gsi))
- {
- gphi *phi = gsi.phi ();
- tree def = PHI_RESULT (phi);
- affine_iv iv;
-
- if (!virtual_operand_p (def)
- && !simple_iv (loop, loop, def, &iv, true))
- {
- tree addr = find_reduc_addr (loop, phi);
- if (addr == NULL_TREE)
- return false;
- struct reduction_info *red = reduction_phi (reduction_list, phi);
- red->reduc_addr = addr;
- }
- }
- }
-
- return true;
-}
-
-/* Return true if LOOP contains phis with ADDR_EXPR in args. */
-
-static bool
-loop_has_phi_with_address_arg (class loop *loop)
-{
- basic_block *bbs = get_loop_body (loop);
- bool res = false;
-
- unsigned i, j;
- gphi_iterator gsi;
- for (i = 0; i < loop->num_nodes; i++)
- for (gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi))
- {
- gphi *phi = gsi.phi ();
- for (j = 0; j < gimple_phi_num_args (phi); j++)
- {
- tree arg = gimple_phi_arg_def (phi, j);
- if (TREE_CODE (arg) == ADDR_EXPR)
- {
- /* This should be handled by eliminate_local_variables, but that
- function currently ignores phis. */
- res = true;
- goto end;
- }
- }
- }
- end:
- free (bbs);
-
- return res;
-}
-
-/* Return true if memory ref REF (corresponding to the stmt at GSI in
- REGIONS_BB[I]) conflicts with the statements in REGIONS_BB[I] after gsi,
- or the statements in REGIONS_BB[I + n]. REF_IS_STORE indicates if REF is a
- store. Ignore conflicts with SKIP_STMT. */
-
-static bool
-ref_conflicts_with_region (gimple_stmt_iterator gsi, ao_ref *ref,
- bool ref_is_store, vec<basic_block> region_bbs,
- unsigned int i, gimple *skip_stmt)
-{
- basic_block bb = region_bbs[i];
- gsi_next (&gsi);
-
- while (true)
- {
- for (; !gsi_end_p (gsi);
- gsi_next (&gsi))
- {
- gimple *stmt = gsi_stmt (gsi);
- if (stmt == skip_stmt)
- {
- if (dump_file)
- {
- fprintf (dump_file, "skipping reduction store: ");
- print_gimple_stmt (dump_file, stmt, 0);
- }
- continue;
- }
-
- if (!gimple_vdef (stmt)
- && !gimple_vuse (stmt))
- continue;
-
- if (gimple_code (stmt) == GIMPLE_RETURN)
- continue;
-
- if (ref_is_store)
- {
- if (ref_maybe_used_by_stmt_p (stmt, ref))
- {
- if (dump_file)
- {
- fprintf (dump_file, "Stmt ");
- print_gimple_stmt (dump_file, stmt, 0);
- }
- return true;
- }
- }
- else
- {
- if (stmt_may_clobber_ref_p_1 (stmt, ref))
- {
- if (dump_file)
- {
- fprintf (dump_file, "Stmt ");
- print_gimple_stmt (dump_file, stmt, 0);
- }
- return true;
- }
- }
- }
- i++;
- if (i == region_bbs.length ())
- break;
- bb = region_bbs[i];
- gsi = gsi_start_bb (bb);
- }
-
- return false;
-}
-
-/* Return true if the bbs in REGION_BBS but not in in_loop_bbs can be executed
- in parallel with REGION_BBS containing the loop. Return the stores of
- reduction results in REDUCTION_STORES. */
-
-static bool
-oacc_entry_exit_ok_1 (bitmap in_loop_bbs, const vec<basic_block> &region_bbs,
- reduction_info_table_type *reduction_list,
- bitmap reduction_stores)
-{
- tree omp_data_i = get_omp_data_i_param ();
-
- unsigned i;
- basic_block bb;
- FOR_EACH_VEC_ELT (region_bbs, i, bb)
- {
- if (bitmap_bit_p (in_loop_bbs, bb->index))
- continue;
-
- gimple_stmt_iterator gsi;
- for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
- gsi_next (&gsi))
- {
- gimple *stmt = gsi_stmt (gsi);
- gimple *skip_stmt = NULL;
-
- if (is_gimple_debug (stmt)
- || gimple_code (stmt) == GIMPLE_COND)
- continue;
-
- ao_ref ref;
- bool ref_is_store = false;
- if (gimple_assign_load_p (stmt))
- {
- tree rhs = gimple_assign_rhs1 (stmt);
- tree base = get_base_address (rhs);
- if (TREE_CODE (base) == MEM_REF
- && operand_equal_p (TREE_OPERAND (base, 0), omp_data_i, 0))
- continue;
-
- tree lhs = gimple_assign_lhs (stmt);
- if (TREE_CODE (lhs) == SSA_NAME
- && has_single_use (lhs))
- {
- use_operand_p use_p;
- gimple *use_stmt;
- struct reduction_info *red;
- single_imm_use (lhs, &use_p, &use_stmt);
- if (gimple_code (use_stmt) == GIMPLE_PHI
- && (red = reduction_phi (reduction_list, use_stmt)))
- {
- tree val = PHI_RESULT (red->keep_res);
- if (has_single_use (val))
- {
- single_imm_use (val, &use_p, &use_stmt);
- if (gimple_store_p (use_stmt))
- {
- unsigned int id
- = SSA_NAME_VERSION (gimple_vdef (use_stmt));
- bitmap_set_bit (reduction_stores, id);
- skip_stmt = use_stmt;
- if (dump_file)
- {
- fprintf (dump_file, "found reduction load: ");
- print_gimple_stmt (dump_file, stmt, 0);
- }
- }
- }
- }
- }
-
- ao_ref_init (&ref, rhs);
- }
- else if (gimple_store_p (stmt))
- {
- ao_ref_init (&ref, gimple_assign_lhs (stmt));
- ref_is_store = true;
- }
- else if (gimple_code (stmt) == GIMPLE_OMP_RETURN)
- continue;
- else if (!gimple_has_side_effects (stmt)
- && !gimple_could_trap_p (stmt)
- && !stmt_could_throw_p (cfun, stmt)
- && !gimple_vdef (stmt)
- && !gimple_vuse (stmt))
- continue;
- else if (gimple_call_internal_p (stmt, IFN_GOACC_DIM_POS))
- continue;
- else if (gimple_code (stmt) == GIMPLE_RETURN)
- continue;
- else
- {
- if (dump_file)
- {
- fprintf (dump_file, "Unhandled stmt in entry/exit: ");
- print_gimple_stmt (dump_file, stmt, 0);
- }
- return false;
- }
-
- if (ref_conflicts_with_region (gsi, &ref, ref_is_store, region_bbs,
- i, skip_stmt))
- {
- if (dump_file)
- {
- fprintf (dump_file, "conflicts with entry/exit stmt: ");
- print_gimple_stmt (dump_file, stmt, 0);
- }
- return false;
- }
- }
- }
-
- return true;
-}
-
-/* Find stores inside REGION_BBS and outside IN_LOOP_BBS, and guard them with
- gang_pos == 0, except when the stores are REDUCTION_STORES. Return true
- if any changes were made. */
-
-static bool
-oacc_entry_exit_single_gang (bitmap in_loop_bbs,
- const vec<basic_block> &region_bbs,
- bitmap reduction_stores)
-{
- tree gang_pos = NULL_TREE;
- bool changed = false;
-
- unsigned i;
- basic_block bb;
- FOR_EACH_VEC_ELT (region_bbs, i, bb)
- {
- if (bitmap_bit_p (in_loop_bbs, bb->index))
- continue;
-
- gimple_stmt_iterator gsi;
- for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
- {
- gimple *stmt = gsi_stmt (gsi);
-
- if (!gimple_store_p (stmt))
- {
- /* Update gsi to point to next stmt. */
- gsi_next (&gsi);
- continue;
- }
-
- if (bitmap_bit_p (reduction_stores,
- SSA_NAME_VERSION (gimple_vdef (stmt))))
- {
- if (dump_file)
- {
- fprintf (dump_file,
- "skipped reduction store for single-gang"
- " neutering: ");
- print_gimple_stmt (dump_file, stmt, 0);
- }
-
- /* Update gsi to point to next stmt. */
- gsi_next (&gsi);
- continue;
- }
-
- changed = true;
-
- if (gang_pos == NULL_TREE)
- {
- tree arg = build_int_cst (integer_type_node, GOMP_DIM_GANG);
- gcall *gang_single
- = gimple_build_call_internal (IFN_GOACC_DIM_POS, 1, arg);
- gang_pos = make_ssa_name (integer_type_node);
- gimple_call_set_lhs (gang_single, gang_pos);
- gimple_stmt_iterator start
- = gsi_start_bb (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
- tree vuse = ssa_default_def (cfun, gimple_vop (cfun));
- gimple_set_vuse (gang_single, vuse);
- gsi_insert_before (&start, gang_single, GSI_SAME_STMT);
- }
-
- if (dump_file)
- {
- fprintf (dump_file,
- "found store that needs single-gang neutering: ");
- print_gimple_stmt (dump_file, stmt, 0);
- }
-
- {
- /* Split block before store. */
- gimple_stmt_iterator gsi2 = gsi;
- gsi_prev (&gsi2);
- edge e;
- if (gsi_end_p (gsi2))
- {
- e = split_block_after_labels (bb);
- gsi2 = gsi_last_bb (bb);
- }
- else
- e = split_block (bb, gsi_stmt (gsi2));
- basic_block bb2 = e->dest;
-
- /* Split block after store. */
- gimple_stmt_iterator gsi3 = gsi_start_bb (bb2);
- edge e2 = split_block (bb2, gsi_stmt (gsi3));
- basic_block bb3 = e2->dest;
-
- gimple *cond
- = gimple_build_cond (EQ_EXPR, gang_pos, integer_zero_node,
- NULL_TREE, NULL_TREE);
- gsi_insert_after (&gsi2, cond, GSI_NEW_STMT);
-
- edge e3 = make_edge (bb, bb3, EDGE_FALSE_VALUE);
- /* FIXME: What is the probability? */
- e3->probability = profile_probability::guessed_never ();
- e->flags = EDGE_TRUE_VALUE;
-
- tree vdef = gimple_vdef (stmt);
- tree vuse = gimple_vuse (stmt);
-
- tree phi_res = copy_ssa_name (vdef);
- gphi *new_phi = create_phi_node (phi_res, bb3);
- replace_uses_by (vdef, phi_res);
- add_phi_arg (new_phi, vuse, e3, UNKNOWN_LOCATION);
- add_phi_arg (new_phi, vdef, e2, UNKNOWN_LOCATION);
-
- /* Update gsi to point to next stmt. */
- bb = bb3;
- gsi = gsi_start_bb (bb);
- }
- }
- }
-
- return changed;
-}
-
-/* Return true if the statements before and after the LOOP can be executed in
- parallel with the function containing the loop. Resolve conflicting stores
- outside LOOP by guarding them such that only a single gang executes them. */
-
-static bool
-oacc_entry_exit_ok (class loop *loop,
- reduction_info_table_type *reduction_list)
-{
- basic_block *loop_bbs = get_loop_body_in_dom_order (loop);
- auto_vec<basic_block> region_bbs
- = get_all_dominated_blocks (CDI_DOMINATORS, ENTRY_BLOCK_PTR_FOR_FN (cfun));
-
- bitmap in_loop_bbs = BITMAP_ALLOC (NULL);
- bitmap_clear (in_loop_bbs);
- for (unsigned int i = 0; i < loop->num_nodes; i++)
- bitmap_set_bit (in_loop_bbs, loop_bbs[i]->index);
-
- bitmap reduction_stores = BITMAP_ALLOC (NULL);
- bool res = oacc_entry_exit_ok_1 (in_loop_bbs, region_bbs, reduction_list,
- reduction_stores);
-
- if (res)
- {
- bool changed = oacc_entry_exit_single_gang (in_loop_bbs, region_bbs,
- reduction_stores);
- if (changed)
- {
- free_dominance_info (CDI_DOMINATORS);
- calculate_dominance_info (CDI_DOMINATORS);
- }
- }
-
- free (loop_bbs);
-
- BITMAP_FREE (in_loop_bbs);
- BITMAP_FREE (reduction_stores);
-
- return res;
-}
-
-/* Detect parallel loops and generate parallel code using libgomp
- primitives. Returns true if some loop was parallelized, false
- otherwise. */
-
-static bool
-parallelize_loops (bool oacc_kernels_p)
-{
- unsigned n_threads;
- bool changed = false;
- class loop *skip_loop = NULL;
- class tree_niter_desc niter_desc;
- struct obstack parloop_obstack;
- HOST_WIDE_INT estimated;
-
- /* Do not parallelize loops in the functions created by parallelization. */
- if (!oacc_kernels_p
- && parallelized_function_p (cfun->decl))
- return false;
-
- /* Do not parallelize loops in offloaded functions. */
- if (!oacc_kernels_p
- && oacc_get_fn_attrib (cfun->decl) != NULL)
- return false;
-
- if (cfun->has_nonlocal_label)
- return false;
-
- /* For OpenACC kernels, n_threads will be determined later; otherwise, it's
- the argument to -ftree-parallelize-loops. */
- if (oacc_kernels_p)
- n_threads = 0;
- else
- n_threads = flag_tree_parallelize_loops;
-
- gcc_obstack_init (&parloop_obstack);
- reduction_info_table_type reduction_list (10);
-
- calculate_dominance_info (CDI_DOMINATORS);
-
- for (auto loop : loops_list (cfun, 0))
- {
- if (loop == skip_loop)
- {
- if (!loop->in_oacc_kernels_region
- && dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file,
- "Skipping loop %d as inner loop of parallelized loop\n",
- loop->num);
-
- skip_loop = loop->inner;
- continue;
- }
- else
- skip_loop = NULL;
-
- reduction_list.empty ();
-
- if (oacc_kernels_p)
- {
- if (!loop->in_oacc_kernels_region)
- continue;
-
- /* Don't try to parallelize inner loops in an oacc kernels region. */
- if (loop->inner)
- skip_loop = loop->inner;
-
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file,
- "Trying loop %d with header bb %d in oacc kernels"
- " region\n", loop->num, loop->header->index);
- }
-
- if (dump_file && (dump_flags & TDF_DETAILS))
- {
- fprintf (dump_file, "Trying loop %d as candidate\n",loop->num);
- if (loop->inner)
- fprintf (dump_file, "loop %d is not innermost\n",loop->num);
- else
- fprintf (dump_file, "loop %d is innermost\n",loop->num);
- }
-
- if (!single_dom_exit (loop))
- {
-
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, "loop is !single_dom_exit\n");
-
- continue;
- }
-
- if (/* And of course, the loop must be parallelizable. */
- !can_duplicate_loop_p (loop)
- || loop_has_blocks_with_irreducible_flag (loop)
- || (loop_preheader_edge (loop)->src->flags & BB_IRREDUCIBLE_LOOP)
- /* FIXME: the check for vector phi nodes could be removed. */
- || loop_has_vector_phi_nodes (loop))
- continue;
-
- estimated = estimated_loop_iterations_int (loop);
- if (estimated == -1)
- estimated = get_likely_max_loop_iterations_int (loop);
- /* FIXME: Bypass this check as graphite doesn't update the
- count and frequency correctly now. */
- if (!flag_loop_parallelize_all
- && !oacc_kernels_p
- && ((estimated != -1
- && (estimated
- < ((HOST_WIDE_INT) n_threads
- * (loop->inner ? 2 : MIN_PER_THREAD) - 1)))
- /* Do not bother with loops in cold areas. */
- || optimize_loop_nest_for_size_p (loop)))
- continue;
-
- if (!try_get_loop_niter (loop, &niter_desc))
- continue;
-
- if (!try_create_reduction_list (loop, &reduction_list, oacc_kernels_p))
- continue;
-
- if (loop_has_phi_with_address_arg (loop))
- continue;
-
- if (!loop->can_be_parallel
- && !loop_parallel_p (loop, &parloop_obstack))
- continue;
-
- if (oacc_kernels_p
- && !oacc_entry_exit_ok (loop, &reduction_list))
- {
- if (dump_file)
- fprintf (dump_file, "entry/exit not ok: FAILED\n");
- continue;
- }
-
- changed = true;
- skip_loop = loop->inner;
-
- if (dump_enabled_p ())
- {
- dump_user_location_t loop_loc = find_loop_location (loop);
- if (loop->inner)
- dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loop_loc,
- "parallelizing outer loop %d\n", loop->num);
- else
- dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loop_loc,
- "parallelizing inner loop %d\n", loop->num);
- }
-
- gen_parallel_loop (loop, &reduction_list,
- n_threads, &niter_desc, oacc_kernels_p);
- }
-
- obstack_free (&parloop_obstack, NULL);
-
- /* Parallelization will cause new function calls to be inserted through
- which local variables will escape. Reset the points-to solution
- for ESCAPED. */
- if (changed)
- pt_solution_reset (&cfun->gimple_df->escaped);
-
- return changed;
-}
-
-/* Parallelization. */
-
-namespace {
-
-const pass_data pass_data_parallelize_loops =
-{
- GIMPLE_PASS, /* type */
- "parloops", /* name */
- OPTGROUP_LOOP, /* optinfo_flags */
- TV_TREE_PARALLELIZE_LOOPS, /* tv_id */
- ( PROP_cfg | PROP_ssa ), /* properties_required */
- 0, /* properties_provided */
- 0, /* properties_destroyed */
- 0, /* todo_flags_start */
- 0, /* todo_flags_finish */
-};
-
-class pass_parallelize_loops : public gimple_opt_pass
-{
-public:
- pass_parallelize_loops (gcc::context *ctxt)
- : gimple_opt_pass (pass_data_parallelize_loops, ctxt),
- oacc_kernels_p (false)
- {}
-
- /* opt_pass methods: */
- virtual bool gate (function *)
- {
- if (oacc_kernels_p)
- return flag_openacc;
- else
- return flag_tree_parallelize_loops > 1;
- }
- virtual unsigned int execute (function *);
- opt_pass * clone () { return new pass_parallelize_loops (m_ctxt); }
- void set_pass_param (unsigned int n, bool param)
- {
- gcc_assert (n == 0);
- oacc_kernels_p = param;
- }
-
- private:
- bool oacc_kernels_p;
-}; // class pass_parallelize_loops
-
-unsigned
-pass_parallelize_loops::execute (function *fun)
-{
- tree nthreads = builtin_decl_explicit (BUILT_IN_OMP_GET_NUM_THREADS);
- if (nthreads == NULL_TREE)
- return 0;
-
- bool in_loop_pipeline = scev_initialized_p ();
- if (!in_loop_pipeline)
- loop_optimizer_init (LOOPS_NORMAL
- | LOOPS_HAVE_RECORDED_EXITS);
-
- if (number_of_loops (fun) <= 1)
- return 0;
-
- if (!in_loop_pipeline)
- {
- rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
- scev_initialize ();
- }
-
- unsigned int todo = 0;
- if (parallelize_loops (oacc_kernels_p))
- {
- fun->curr_properties &= ~(PROP_gimple_eomp);
-
- checking_verify_loop_structure ();
-
- todo |= TODO_update_ssa;
- }
-
- if (!in_loop_pipeline)
- {
- scev_finalize ();
- loop_optimizer_finalize ();
- }
-
- return todo;
-}
-
-} // anon namespace
-
-gimple_opt_pass *
-make_pass_parallelize_loops (gcc::context *ctxt)
-{
- return new pass_parallelize_loops (ctxt);
-}