diff --git a/gcc/expr.cc b/gcc/expr.cc index 78c839ab425..c90cde35006 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -8832,7 +8832,8 @@ expand_cond_expr_using_cmove (tree treeop0 ATTRIBUTE_UNUSED, expanding_cond_expr_using_cmove = true; start_sequence (); expand_operands (treeop1, treeop2, - temp, &op1, &op2, EXPAND_NORMAL); + mode == orig_mode ? temp : NULL_RTX, &op1, &op2, + EXPAND_NORMAL); if (TREE_CODE (treeop0) == SSA_NAME && (srcstmt = get_def_for_expr_class (treeop0, tcc_comparison))) diff --git a/gcc/testsuite/gcc.c-torture/compile/pr106030.c b/gcc/testsuite/gcc.c-torture/compile/pr106030.c new file mode 100644 index 00000000000..7514b348ff9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr106030.c @@ -0,0 +1,16 @@ +/* PR middle-end/106030 */ + +int a, b, c; + +char +foo (int x, int y) +{ + return x * y; +} + +void +bar (void) +{ + char d = (foo <= b) * a; + c = foo (2 != bar, d); +}