]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Make force_subreg emit nothing on failure
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 18 Jun 2024 11:22:30 +0000 (12:22 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 18 Jun 2024 11:22:30 +0000 (12:22 +0100)
While adding more uses of force_subreg, I realised that it should
be more careful to emit no instructions on failure.  This kind of
failure should be very rare, so I don't think it's a case worth
optimising for.

gcc/
* explow.cc (force_subreg): Emit no instructions on failure.

gcc/explow.cc

index f6843398c4b02011735e78619c7a928bc34d6b04..bd93c87806492e2e68164229ae5111b00842b4f1 100644 (file)
@@ -756,8 +756,12 @@ force_subreg (machine_mode outermode, rtx op,
   if (x)
     return x;
 
+  auto *start = get_last_insn ();
   op = copy_to_mode_reg (innermode, op);
-  return simplify_gen_subreg (outermode, op, innermode, byte);
+  rtx res = simplify_gen_subreg (outermode, op, innermode, byte);
+  if (!res)
+    delete_insns_since (start);
+  return res;
 }
 
 /* If X is a memory ref, copy its contents to a new temp reg and return