[nvptx] Split up function ref plus const

With test-case gcc.c-torture/compile/pr92231.c, we run into:
...
nvptx-as: ptxas terminated with signal 11 [Segmentation fault], core dumped^M
compiler exited with status 1
FAIL: gcc.c-torture/compile/pr92231.c   -O0  (test for excess errors)
...
due to using a function reference plus constant as operand:
...
  mov.u64 %r24,bar+4096';
...

Fix this by splitting such an insn into:
...
  mov.u64 %r24,bar';
  add.u64 %r24,%r24,4096';
...

Tested on nvptx.

gcc/ChangeLog:

	* config/nvptx/nvptx.md: Don't allow operand containing sum of
	function ref and const.
This commit is contained in:
Tom de Vries 2020-09-23 17:35:23 +02:00
parent 74b27d8eed
commit 37c3c29739
1 changed files with 18 additions and 0 deletions

View File

@ -146,6 +146,13 @@
return true;
})
;; Test for a function symbol ref operand
(define_predicate "symbol_ref_function_operand"
(match_code "symbol_ref")
{
return SYMBOL_REF_FUNCTION_P (op);
})
(define_attr "predicable" "false,true"
(const_string "true"))
@ -241,6 +248,17 @@
}
[(set_attr "subregs_ok" "true")])
;; ptxas segfaults on 'mov.u64 %r24,bar+4096', so break it up.
(define_split
[(set (match_operand:DI 0 "nvptx_register_operand")
(const:DI (plus:DI (match_operand:DI 1 "symbol_ref_function_operand")
(match_operand 2 "const_int_operand"))))]
""
[(set (match_dup 0) (match_dup 1))
(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
]
"")
(define_insn "*mov<mode>_insn"
[(set (match_operand:SDFM 0 "nonimmediate_operand" "=R,R,m")
(match_operand:SDFM 1 "general_operand" "RF,m,R"))]