aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/optabs.cc2
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/condmove-1.c9
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/optabs.cc b/gcc/optabs.cc
index f0a048a..6a34276 100644
--- a/gcc/optabs.cc
+++ b/gcc/optabs.cc
@@ -5131,6 +5131,7 @@ emit_conditional_move (rtx target, struct rtx_comparison comp,
/* If we are optimizing, force expensive constants into a register
but preserve an eventual equality with op2/op3. */
if (CONSTANT_P (orig_op0) && optimize
+ && cmpmode == mode
&& (rtx_cost (orig_op0, mode, COMPARE, 0,
optimize_insn_for_speed_p ())
> COSTS_N_INSNS (1))
@@ -5142,6 +5143,7 @@ emit_conditional_move (rtx target, struct rtx_comparison comp,
op3p = XEXP (comparison, 0) = force_reg (cmpmode, orig_op0);
}
if (CONSTANT_P (orig_op1) && optimize
+ && cmpmode == mode
&& (rtx_cost (orig_op1, mode, COMPARE, 0,
optimize_insn_for_speed_p ())
> COSTS_N_INSNS (1))
diff --git a/gcc/testsuite/gcc.c-torture/compile/condmove-1.c b/gcc/testsuite/gcc.c-torture/compile/condmove-1.c
new file mode 100644
index 0000000..3fcc591
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/condmove-1.c
@@ -0,0 +1,9 @@
+/* PR middle-end/111260 */
+
+/* Used to ICE while expansion of the `(a == b) ? b : 0;` */
+int f1(long long a)
+{
+ int b = 822920;
+ int t = a == b;
+ return t * (int)b;
+}