On 29/01/2020 12:30, Thomas Schwinge wrote:
Hi Andrew!

On 2019-11-22T11:06:14+0000, Andrew Stubbs <a...@codesourcery.com> wrote:
This test case causes an ICE (reformatted for email):

    void test(int k)
    {
      unsigned int x = 1;
    #pragma acc parallel loop async(x)
      for (int i = 0; i < k; i++) { }
    }

Curious, why didn't you include such a test case in your actual patch?

Because I'm a terrible person.

    t.c: In function 'test':
    t.c:4:9: error: invalid argument to gimple call
        4 | #pragma acc parallel loop async(x)
          |         ^~~
    (int) x
    __builtin_GOACC_parallel_keyed (-1, test._omp_fn.0, 1,
                                    &.omp_data_arr.3, &.omp_data_sizes.4,
                                    &.omp_data_kinds.5, 536936447,
                                   (int) x, 0);
    during GIMPLE pass: ompexp
    dump file: t.c.013t.ompexp
    t.c:4:9: internal compiler error: verify_gimple failed

The problem is that "x" needs to be cast to "int" (from "unsigned int")
before calling the function, and that's not valid in a gimple call.

ACK, thanks.

The attached patch assigns the "(int) x" to a temporary and passes that
to the function instead.

OK to commit?

A little bit more thoroughness, please.  :-)

As can be seen in the code a few lines below, the very same problem also
exists for the 'wait' clause; it seems reasonable to fix both at the same
time.  This is not a recent regression, but a user-visible valid-code ICE
that has existed "forever"; I filed <https://gcc.gnu.org/PR93488> "ICE in
type-cast 'async', 'wait' clauses" for tracking.  This problem is similar
to the OpenMP 'device' clause <https://gcc.gnu.org/PR71758> "ICE in
verify_gimple_in_cfg, at tree-cfg.c:5212"; I suggest we also use
'force_gimple_operand_gsi' instead of manually doing your suggested
'create_tmp_var', 'gimple_build_assign', 'gsi_insert_before'.  Include a
test case that covers all relevant code paths; I've attached a test case
to the PR, but I've not verified whether "that covers *all* relevant code
paths".  This should then be backported to all GCC release branches; I
can easily test the backports for you, if you're not already set up to do
such testing.

OK, I'll take a look at your testcase and cook up a patch.

Today I learned about force_gimple_operand_gsi. :-)

Andrew

Reply via email to