diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md index e7d3630d4c4..d08afd4378b 100644 --- a/gcc/config/nvptx/nvptx.md +++ b/gcc/config/nvptx/nvptx.md @@ -1671,15 +1671,8 @@ (match_operand 1 "nvptx_register_operand")] "" { - if (!TARGET_SOFT_STACK - && TARGET_PTX_7_3 - && TARGET_SM52) + if (!TARGET_SOFT_STACK) emit_insn (gen_nvptx_alloca (Pmode, operands[0], operands[1])); - else if (!TARGET_SOFT_STACK) - { - sorry ("dynamic stack allocation not supported"); - emit_insn (gen_nop ()); - } else if (TARGET_SOFT_STACK) { emit_move_insn (stack_pointer_rtx, @@ -1696,19 +1689,28 @@ [(set (match_operand:P 0 "nvptx_register_operand" "=R") (unspec:P [(match_operand:P 1 "nvptx_nonmemory_operand" "Ri")] UNSPEC_ALLOCA))] - "TARGET_PTX_7_3 - && TARGET_SM52" + "" { - /* Convert the address from '.local' state space to generic. That way, - we don't have to use 'st.local', 'ld.local', and can easily pass the - address to other "generic functions". - TODO 'gcc.target/nvptx/alloca-5.c' */ - output_asm_insn ("{", NULL); - output_asm_insn ("\\t.reg%t0\\t%0_local;", operands); - output_asm_insn ("\\talloca%u0\\t%0_local, %1;", operands); - output_asm_insn ("\\tcvta.local%u0\\t%0, %0_local;", operands); - output_asm_insn ("}", NULL); - return ""; + if (TARGET_PTX_7_3 + && TARGET_SM52) + { + /* Convert the address from '.local' state space to generic. That way, + we don't have to use 'st.local', 'ld.local', and can easily pass the + address to other "generic functions". + TODO 'gcc.target/nvptx/alloca-5.c' */ + output_asm_insn ("{", NULL); + output_asm_insn ("\\t.reg%t0\\t%0_local;", operands); + output_asm_insn ("\\talloca%u0\\t%0_local, %1;", operands); + output_asm_insn ("\\tcvta.local%u0\\t%0, %0_local;", operands); + output_asm_insn ("}", NULL); + return ""; + } + else + { + sorry_at (INSN_LOCATION (insn), + "dynamic stack allocation not supported"); + return ""; + } } [(set_attr "predicable" "no")]) diff --git a/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O0-sm_30.c b/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O0-sm_30.c index c948ccc1f1b..32e85e64cc5 100644 --- a/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O0-sm_30.c +++ b/gcc/testsuite/gcc.target/nvptx/alloca-1-unused-O0-sm_30.c @@ -1,9 +1,17 @@ -/* { dg-do compile } */ +/* { dg-do assemble } */ /* { dg-options {-O0 -mno-soft-stack} } */ /* { dg-additional-options -march=sm_30 } */ +/* { dg-additional-options -save-temps } */ +/* { dg-final { check-function-bodies {** } {} } } */ void f(void) { __builtin_alloca(123); /* { dg-warning "ignoring return value of '__builtin_alloca' declared with attribute 'warn_unused_result'" } */ - /* { dg-message {sorry, unimplemented: dynamic stack allocation not supported} {} { target *-*-* } .-1 } */ + /* { dg-bogus {sorry, unimplemented: dynamic stack allocation not supported} {} { target *-*-* } .-1 } */ } +/* +** f: +** \.visible \.func f +** { +** ret; +*/