Skip to content
Snippets Groups Projects
Commit 2fd215b0 authored by Roger Sayle's avatar Roger Sayle
Browse files

PR target/106278: Keep REG_EQUAL notes consistent during TImode STV on x86_64.

This patch resolves PR target/106278 a regression on x86_64 caused by my
recent TImode STV improvements.  Now that TImode STV can handle comparisons
such as "(set (regs:CC) (compare:CC (reg:TI) ...))" the convert_insn method
sensibly checks that the mode of the SET_DEST is TImode before setting
it to V1TImode [to avoid V1TImode appearing on the hard reg CC_FLAGS.

Hence the current code looks like:

      if (GET_MODE (dst) == TImode)
 	{
 	  tmp = find_reg_equal_equiv_note (insn);
 	  if (tmp && GET_MODE (XEXP (tmp, 0)) == TImode)
 	    PUT_MODE (XEXP (tmp, 0), V1TImode);
	  PUT_MODE (dst, V1TImode);
	  fix_debug_reg_uses (dst);
 	}
      break;

which checks GET_MODE (dst) before calling PUT_MODE, and when a
change is made updating the REG_EQUAL_NOTE tmp if it exists.

The logical flaw (oversight) is that due to RTL sharing, the destination
of this set may already have been updated to V1TImode, as this chain is
being converted, but we still need to update any REG_EQUAL_NOTE that
still has TImode.  Hence the correct code is actually:

      if (GET_MODE (dst) == TImode)
 	{
	  PUT_MODE (dst, V1TImode);
	  fix_debug_reg_uses (dst);
	}
      if (GET_MODE (dst) == V1TImode)
	{
 	  tmp = find_reg_equal_equiv_note (insn);
 	  if (tmp && GET_MODE (XEXP (tmp, 0)) == TImode)
 	    PUT_MODE (XEXP (tmp, 0), V1TImode);
 	}
      break;

While fixing this behavior, I noticed I had some indentation whitespace
issues and some vestigial dead code in this function/method that I've
taken the liberty of cleaning up (as obvious) in this patch.

2022-07-15  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	PR target/106278
	* config/i386/i386-features.cc (general_scalar_chain::convert_insn):
	Fix indentation whitespace.
	(timode_scalar_chain::fix_debug_reg_uses): Likewise.
	(timode_scalar_chain::convert_insn): Delete dead code.
	Update TImode REG_EQUAL_NOTE even if the SET_DEST is already V1TI.
	Fix indentation whitespace.
	(convertible_comparison_p): Likewise.
	(timode_scalar_to_vector_candidate_p): Likewise.

gcc/testsuite/ChangeLog
	* gcc.dg/pr106278.c: New test case.
parent 3aab916f
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment