The attached change fixes PR target/79027 On gcc-8 and gcc-7, under some conditions that are a bit hard to reproduce, we get a floating point exception when regcprop.c tries to change a SImode value to BLKmode. The attached patch to pa_cannot_change_mode_class reject such changes. As a result, fold-const.c compiles successfully.
The bug is latent in all active branches. Tested on hppa-unknown-linux-gnu and hppa2.0w-hp-hpux11.11 trunk. Committed to trunk. Dave -- John David Anglin dave.ang...@bell.net
2017-05-10 John David Anglin <dang...@gcc.gnu.org> PR target/79027 * config/pa/pa.c (pa_cannot_change_mode_class): Reject changes to/from modes with zero size. Enhance comment. Index: config/pa/pa.c =================================================================== --- config/pa/pa.c (revision 247726) +++ config/pa/pa.c (working copy) @@ -9962,19 +9981,23 @@ if (from == to) return false; + if (GET_MODE_SIZE (from) == GET_MODE_SIZE (to)) + return false; + + /* Reject changes to/from modes with zero size. */ + if (!GET_MODE_SIZE (from) || !GET_MODE_SIZE (to)) + return true; + /* Reject changes to/from complex and vector modes. */ if (COMPLEX_MODE_P (from) || VECTOR_MODE_P (from) || COMPLEX_MODE_P (to) || VECTOR_MODE_P (to)) return true; - if (GET_MODE_SIZE (from) == GET_MODE_SIZE (to)) - return false; - - /* There is no way to load QImode or HImode values directly from - memory. SImode loads to the FP registers are not zero extended. - On the 64-bit target, this conflicts with the definition of - LOAD_EXTEND_OP. Thus, we can't allow changing between modes - with different sizes in the floating-point registers. */ + /* There is no way to load QImode or HImode values directly from memory + to a FP register. SImode loads to the FP registers are not zero + extended. On the 64-bit target, this conflicts with the definition + of LOAD_EXTEND_OP. Thus, we can't allow changing between modes with + different sizes in the floating-point registers. */ if (MAYBE_FP_REG_CLASS_P (rclass)) return true;