https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79286
Bernd Edlinger <bernd.edlinger at hotmail dot de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bernd.edlinger at hotmail dot de --- Comment #12 from Bernd Edlinger <bernd.edlinger at hotmail dot de> --- Hi Jeff, it looks like it is possible that may_trap_p returns always wrong information if -m32 -fPIC is used. What do you think about this? Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c (revision 245714) +++ gcc/rtlanal.c (working copy) @@ -645,8 +645,23 @@ case PLUS: /* An address is assumed not to trap if: - it is the pic register plus a constant. */ - if (XEXP (x, 0) == pic_offset_table_rtx && CONSTANT_P (XEXP (x, 1))) - return 0; + if (XEXP (x, 0) == pic_offset_table_rtx + && GET_CODE (XEXP (x, 1)) == CONST) + { + x = XEXP (XEXP (x, 1), 0); + if (GET_CODE (x) == UNSPEC + && GET_CODE (XVECEXP (x, 0, 0)) == SYMBOL_REF) + return rtx_addr_can_trap_p_1(XVECEXP (x, 0, 0), + offset, size, mode, unaligned_mems); + if (GET_CODE (x) == PLUS + && GET_CODE (XEXP (x, 0)) == UNSPEC + && GET_CODE (XVECEXP (XEXP (x, 0), 0, 0)) == SYMBOL_REF + && CONST_INT_P (XEXP (x, 1))) + return rtx_addr_can_trap_p_1(XVECEXP (XEXP (x, 0), 0, 0), + offset + INTVAL (XEXP (x, 1)), + size, mode, unaligned_mems); + return 1; + } /* - or it is an address that can't trap plus a constant integer. */ if (CONST_INT_P (XEXP (x, 1))