insns = get_insns ();
end_sequence ();
+ bool trapv = trapv_binoptab_p (binoptab);
target = gen_reg_rtx (mode);
emit_libcall_block_1 (insns, target, value,
- gen_rtx_fmt_ee (optab_to_code (binoptab),
- mode, op0, op1),
- trapv_binoptab_p (binoptab));
+ trapv ? NULL_RTX
+ : gen_rtx_fmt_ee (optab_to_code (binoptab),
+ mode, op0, op1), trapv);
return target;
}
end_sequence ();
target = gen_reg_rtx (outmode);
- eq_value = gen_rtx_fmt_e (optab_to_code (unoptab), mode, op0);
- if (GET_MODE_SIZE (outmode) < GET_MODE_SIZE (mode))
- eq_value = simplify_gen_unary (TRUNCATE, outmode, eq_value, mode);
- else if (GET_MODE_SIZE (outmode) > GET_MODE_SIZE (mode))
- eq_value = simplify_gen_unary (ZERO_EXTEND, outmode, eq_value, mode);
- emit_libcall_block_1 (insns, target, value, eq_value,
- trapv_unoptab_p (unoptab));
+ bool trapv = trapv_unoptab_p (unoptab);
+ if (trapv)
+ eq_value = NULL_RTX;
+ else
+ {
+ eq_value = gen_rtx_fmt_e (optab_to_code (unoptab), mode, op0);
+ if (GET_MODE_SIZE (outmode) < GET_MODE_SIZE (mode))
+ eq_value = simplify_gen_unary (TRUNCATE, outmode, eq_value, mode);
+ else if (GET_MODE_SIZE (outmode) > GET_MODE_SIZE (mode))
+ eq_value = simplify_gen_unary (ZERO_EXTEND,
+ outmode, eq_value, mode);
+ }
+ emit_libcall_block_1 (insns, target, value, eq_value, trapv);
return target;
}
}
last = emit_move_insn (target, result);
- set_dst_reg_note (last, REG_EQUAL, copy_rtx (equiv), target);
+ if (equiv)
+ set_dst_reg_note (last, REG_EQUAL, copy_rtx (equiv), target);
if (final_dest != target)
emit_move_insn (final_dest, target);
--- /dev/null
+/* { dg-do run } */
+/* With -flto this degenerates to constant folding which doesn't work. */
+/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
+/* { dg-additional-options "-ftrapv" } */
+/* { dg-require-effective-target trapping } */
+/* { dg-require-fork unused } */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+/* Verify SImode operations properly trap. PR middle-end/68046 */
+
+int i = 0x7fffffff;
+
+int main(void)
+{
+ pid_t child = fork ();
+ int status = 0;
+ if (child == 0)
+ {
+ volatile int x = i + 1 < i;
+ exit (0);
+ }
+ else if (child == -1)
+ return 0;
+ if (wait (&status) == child
+ && status == 0)
+ abort ();
+ return 0;
+}