public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR 109919: ICE in emit_move_insn with some bit tests
@ 2023-05-21  1:09 Andrew Pinski
  2023-05-21  1:25 ` Jeff Law
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Pinski @ 2023-05-21  1:09 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

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                                      | 2 +-
 gcc/testsuite/gcc.c-torture/compile/pr109919-1.c | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr109919-1.c

diff --git a/gcc/expr.cc b/gcc/expr.cc
index 2070198acda..02f24c00148 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -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
index 00000000000..bb612a1f020
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr109919-1.c
@@ -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;
+}
-- 
2.31.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-05-21  4:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-21  1:09 [PATCH] Fix PR 109919: ICE in emit_move_insn with some bit tests Andrew Pinski
2023-05-21  1:25 ` Jeff Law
2023-05-21  3:05   ` Andrew Pinski
2023-05-21  3:25     ` Jeff Law
2023-05-21  3:28       ` Andrew Pinski
2023-05-21  3:32         ` Andrew Pinski
2023-05-21  3:47           ` Andrew Pinski
2023-05-21  4:34         ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).