diff mbox series

[3/3] VAX: Handle subtracting from self with QMATH DImode add/sub

Message ID alpine.LFD.2.21.2012101642270.2104409@eddie.linux-mips.org
State Accepted
Headers show
Series VAX: QMATH DImode add/sub fixes | expand

Commit Message

Maciej W. Rozycki Dec. 11, 2020, 8:48 p.m. UTC
Remove an assertion the failure of which has not been actually observed, 
but which appears clearly dangerous, for when the QMATH DImode add/sub 
handler is invoked with the subtrahend and the minuend both the same.
Instead handle the operation by emitting a move of constant 0 to the 
output operand.  Adjust the relevant inline comment accordingly.

	gcc/
	* config/vax/vax.c (vax_expand_addsub_di_operands): Handle equal
	input operands with subtraction.
---
 gcc/config/vax/vax.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Jeff Law Dec. 13, 2020, 4:04 p.m. UTC | #1
On 12/11/20 1:48 PM, Maciej W. Rozycki wrote:
> Remove an assertion the failure of which has not been actually observed, 
> but which appears clearly dangerous, for when the QMATH DImode add/sub 
> handler is invoked with the subtrahend and the minuend both the same.
> Instead handle the operation by emitting a move of constant 0 to the 
> output operand.  Adjust the relevant inline comment accordingly.
>
> 	gcc/
> 	* config/vax/vax.c (vax_expand_addsub_di_operands): Handle equal
> 	input operands with subtraction.
OK
jeff
diff mbox series

Patch

Index: gcc/gcc/config/vax/vax.c
===================================================================
--- gcc.orig/gcc/config/vax/vax.c
+++ gcc/gcc/config/vax/vax.c
@@ -2042,12 +2042,14 @@  vax_expand_addsub_di_operands (rtx * ope
     }
   else
     {
-      /* If are adding the same value together, that's really a multiply by 2,
-	 and that's just a left shift of 1.  */
+      /* If we are adding a value to itself, that's really a multiply by 2,
+	 and that's just a left shift by 1.  If subtracting, it's just 0.  */
       if (rtx_equal_p (operands[1], operands[2]))
 	{
-	  gcc_assert (code != MINUS);
-	  emit_insn (gen_ashldi3 (operands[0], operands[1], const1_rtx));
+	  if (code == PLUS)
+	    emit_insn (gen_ashldi3 (operands[0], operands[1], const1_rtx));
+	  else
+	    emit_move_insn (operands[0], const0_rtx);
 	  return;
 	}