]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix PR 109919: ICE in emit_move_insn with some bit tests
authorAndrew Pinski <apinski@marvell.com>
Sat, 20 May 2023 21:14:23 +0000 (21:14 +0000)
committerAndrew Pinski <apinski@marvell.com>
Sun, 21 May 2023 01:11:24 +0000 (01:11 +0000)
The problem is I used expand_expr with the target but
we don't want to use the target here as it is the wrong
mode for the original expression. The testcase would ICE
deap down while trying to do a move to use the target.
Anyways just calling expand_expr with NULL_EXPR fixes
the issue.

Committed as obvious after a bootstrap/test on x86_64-linux-gnu.

PR middle-end/109919

gcc/ChangeLog:

* expr.cc (expand_single_bit_test): Don't use the
target for expand_expr.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/pr109919-1.c: New test.

gcc/expr.cc
gcc/testsuite/gcc.c-torture/compile/pr109919-1.c [new file with mode: 0644]

index 6849c9627d09d1b25fcc702125d21c2abad3e0ca..30c58c8dc5c9dea17af74c7d1b42de5d0d8b6bb9 100644 (file)
@@ -12956,7 +12956,7 @@ expand_single_bit_test (location_t loc, enum tree_code code,
   intermediate_type = ops_unsigned ? unsigned_type : signed_type;
   inner = fold_convert_loc (loc, intermediate_type, inner);
 
-  rtx inner0 = expand_expr (inner, target, VOIDmode, EXPAND_NORMAL);
+  rtx inner0 = expand_expr (inner, NULL_RTX, VOIDmode, EXPAND_NORMAL);
 
   inner0 = extract_bit_field (inner0, 1, bitnum, 1, target,
                              operand_mode, mode, 0, NULL);
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr109919-1.c b/gcc/testsuite/gcc.c-torture/compile/pr109919-1.c
new file mode 100644 (file)
index 0000000..bb612a1
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-options "-fno-tree-dce -fno-tree-vrp" } */
+int a;
+int main() {
+  int b = 1;
+  while (a) {
+    short c = b && ((a || a) & (a * c));
+  }
+  return 0;
+}