https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91604

--- Comment #3 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Martin Liška from comment #2)
> (In reply to Uroš Bizjak from comment #1)
> > Hm, I can't trigger the failure with gcc version 10.0.0 20190829
> > (experimental).
> 
> https://godbolt.org/z/T068Mt

Sorry, I can't confirm. The pattern *one_cmpldi2_doubleword is correctly
protected by ix86_unary_operator_ok:

(define_insn_and_split "*one_cmpldi2_doubleword"
  [(set (match_operand:DI 0 "nonimmediate_operand")
        (not:DI (match_operand:DI 1 "nonimmediate_operand")))]
  "!TARGET_64BIT && TARGET_STV && TARGET_SSE2
   && ix86_unary_operator_ok (NOT, DImode, operands)
   && can_create_pseudo_p ()"
  "#"
  "&& 1"
  [(set (match_dup 0)
        (not:SI (match_dup 1)))
   (set (match_dup 2)
        (not:SI (match_dup 3)))]
  "split_double_mode (DImode, &operands[0], 2, &operands[0], &operands[2]);")

which checks exactly for the operand mismatch that ICEs this test:

/* Return TRUE or FALSE depending on whether the unary operator meets the
   appropriate constraints.  */

bool
ix86_unary_operator_ok (enum rtx_code,
                        machine_mode,
                        rtx operands[2])
{
  /* If one of operands is memory, source and destination must match.  */
  if ((MEM_P (operands[0])
       || MEM_P (operands[1]))
      && ! rtx_equal_p (operands[0], operands[1]))
    return false;
  return true;
}

split1 dump shows:

(insn 5 2 6 2 (set (mem/c:SI (symbol_ref:SI ("v") [flags 0x2]  <var_decl
0x7f191c1c6ab0 v>) [1 v+0 S4 A64])
        (not:SI (mem/c:SI (symbol_ref:SI ("v") [flags 0x2]  <var_decl
0x7f191c1c6ab0 v>) [1 v+0 S4 A64]))) "pr91604.c":2:17 504 {*one_cmplsi2_1}
     (nil))
(insn 6 5 9 2 (set (mem/c:SI (const:SI (plus:SI (symbol_ref:SI ("v") [flags
0x2]  <var_decl 0x7f191c1c6ab0 v>)
                    (const_int 4 [0x4]))) [1 v+4 S4 A32])
        (not:SI (mem/c:SI (const:SI (plus:SI (symbol_ref:SI ("v") [flags 0x2] 
<var_decl 0x7f191c1c6ab0 v>)
                        (const_int 4 [0x4]))) [1 v+4 S4 A32])))
"pr91604.c":2:17 504 {*one_cmplsi2_1}
     (nil))

There is no way that mismatched memory arguments enter *one_cmpldi2_doubleword,
so perhaps adjust_address in split_double_mode is doing some "optimization".

Reply via email to