diff mbox

[PR70729] The second part of patch.

Message ID CAEoMCqTqHsxOJ9J7NCH2=6qx-JiDpqPd3shoRKhw5Wn8U0QNgA@mail.gmail.com
State New
Headers show

Commit Message

Yuri Rumyantsev June 30, 2016, 1:48 p.m. UTC
Hi Jacub,

Thanks for your help.
Could you please look at the following simple patch which cures
regression - we need to nullify loop safelen  field in
adjust_simduid_builtins:


Thanks.
Yuri.

2016-06-30 15:21 GMT+03:00 Jakub Jelinek <jakub@redhat.com>:
> On Thu, Jun 30, 2016 at 03:16:51PM +0300, Yuri Rumyantsev wrote:
>> Hi Grüße.
>>
>> Could you please tell me how to reproduce your regression - did not
>> see any new failures in my local area:
>>
>> PASS: libgomp.fortran/examples-4/simd-2.f90   -O0  (test for excess errors)
>> PASS: libgomp.fortran/examples-4/simd-2.f90   -O0  execution test
>> PASS: libgomp.fortran/examples-4/simd-2.f90   -O1  (test for excess errors)
>> PASS: libgomp.fortran/examples-4/simd-2.f90   -O1  execution test
>> PASS: libgomp.fortran/examples-4/simd-2.f90   -O2  (test for excess errors)
>> PASS: libgomp.fortran/examples-4/simd-2.f90   -O2  execution test
>> PASS: libgomp.fortran/examples-4/simd-2.f90   -O3 -fomit-frame-pointer
>> -funroll-loops -fpeel-loops -ftracer -finline-functions  (test for
>> excess errors)
>> PASS: libgomp.fortran/examples-4/simd-2.f90   -O3 -fomit-frame-pointer
>> -funroll-loops -fpeel-loops -ftracer -finline-functions  execution
>> test
>> PASS: libgomp.fortran/examples-4/simd-2.f90   -O3 -g  (test for excess errors)
>> PASS: libgomp.fortran/examples-4/simd-2.f90   -O3 -g  execution test
>> PASS: libgomp.fortran/examples-4/simd-2.f90   -Os  (test for excess errors)
>> PASS: libgomp.fortran/examples-4/simd-2.f90   -Os  execution test
>>
>> I used HASWELL machine for it since test requires target avx.
>
> It fails everywhere for me, without offloading configured, both 32-bit and 64-bit.
> $ /home/jakub/src/gcc/obj20/gcc/xgcc -B/home/jakub/src/gcc/obj20/gcc/ ../../../../libgomp/testsuite/libgomp.fortran/examples-4/simd-2.f90   -B/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp/ -B/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp/.libs -I/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp -I../../../../libgomp/testsuite/../../include -I../../../../libgomp/testsuite/.. -fmessage-length=0 -fno-diagnostics-show-caret -Wno-hsa -fdiagnostics-color=never -fopenmp -B/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp/../libquadmath/.libs/   -O2  -msse2 -mavx -B/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp/../libgfortran/.libs -fintrinsic-modules-path=/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp   -L/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp/.libs -L/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp/../libquadmath/.libs/ -L/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp/../libgfortran/.libs -lgfortran -lm  -o ./simd-2.exe -Wl,-rpath,../.libs/ -march=haswell
> $ ./simd-2.exe
>
> Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
>
> Backtrace for this error:
> #0  0x7F7548CDBD58
> #1  0x7F7548CDAEE0
> #2  0x3405234A4F
> #3  0x400849 in __simd2_mod_MOD_work
> #4  0x4008D4 in MAIN__ at simd-2.f90:?
> Segmentation fault (core dumped)
>
> With/without -march=haswell, -mtune=haswell etc.
>
>         Jakub

Comments

Thomas Schwinge June 30, 2016, 2:25 p.m. UTC | #1
Hi!

On Thu, 30 Jun 2016 16:48:25 +0300, Yuri Rumyantsev <ysrumyan@gmail.com> wrote:
> Thanks for your help.
> Could you please look at the following simple patch which cures
> regression - we need to nullify loop safelen  field in
> adjust_simduid_builtins:
> 
> diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
> index 2669813..f70380c 100644
> --- a/gcc/tree-vectorizer.c
> +++ b/gcc/tree-vectorizer.c
> @@ -204,6 +204,10 @@ adjust_simduid_builtins (hash_table<simduid_to_vf> *htab)
>           gcc_assert (TREE_CODE (arg) == SSA_NAME);
>           simduid_to_vf *p = NULL, data;
>           data.simduid = DECL_UID (SSA_NAME_VAR (arg));
> +         /* Need to nullify safelen fielf of loop since it's vale is not
> +            valid after transformation.  */
> +         if (bb->loop_father && bb->loop_father->safelen > 0)
> +           bb->loop_father->safelen = 0;
>           if (htab)
>             {
>               p = htab->find (&data);

Quickly testing that by manually compiling
libgomp.fortran/examples-4/simd-2.f90 with -O2, I see that the dump files
generated by -fdump-tree-all are now back to what they were before your
change, and when manually running that executable, it exits normally, and
the following valgrind diagnostics no longer show up (that I saw after
your change):

    ==5942== Use of uninitialised value of size 8
    ==5942==    at 0x40083D: __simd2_mod_MOD_work (simd-2.f90:18)
    ==5942==    by 0x4008D4: MAIN__ (simd-2.f90:68)
    ==5942==    by 0x4005DC: main (simd-2.f90:58)
    ==5942== 
    ==5942== Use of uninitialised value of size 8
    ==5942==    at 0x400845: __simd2_mod_MOD_work (simd-2.f90:18)
    ==5942==    by 0x4008D4: MAIN__ (simd-2.f90:68)
    ==5942==    by 0x4005DC: main (simd-2.f90:58)
    ==5942== 
    ==5942== Invalid read of size 8
    ==5942==    at 0x400845: __simd2_mod_MOD_work (simd-2.f90:18)
    ==5942==    by 0x4008D4: MAIN__ (simd-2.f90:68)
    ==5942==    by 0x4005DC: main (simd-2.f90:58)
    ==5942==  Address 0x5d3 is not stack'd, malloc'd or (recently) free'd

(Address 0x5d3 looks highly suspicious.)

In case that's relevant:

    $ sed -e '/^$/Q' < /proc/cpuinfo 
    processor       : 0
    vendor_id       : GenuineIntel
    cpu family      : 6
    model           : 58
    model name      : Intel(R) Core(TM) i7-3740QM CPU @ 2.70GHz
    stepping        : 9
    microcode       : 0x1b
    cpu MHz         : 1744.875
    cache size      : 6144 KB
    physical id     : 0
    siblings        : 8
    core id         : 0
    cpu cores       : 4
    apicid          : 0
    initial apicid  : 0
    fpu             : yes
    fpu_exception   : yes
    cpuid level     : 13
    wp              : yes
    flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt
    bugs            :
    bogomips        : 5382.58
    clflush size    : 64
    cache_alignment : 64
    address sizes   : 36 bits physical, 48 bits virtual
    power management:


Grüße
 Thomas


> 2016-06-30 15:21 GMT+03:00 Jakub Jelinek <jakub@redhat.com>:
> > On Thu, Jun 30, 2016 at 03:16:51PM +0300, Yuri Rumyantsev wrote:
> >> Hi Grüße.
> >>
> >> Could you please tell me how to reproduce your regression - did not
> >> see any new failures in my local area:
> >>
> >> PASS: libgomp.fortran/examples-4/simd-2.f90   -O0  (test for excess errors)
> >> PASS: libgomp.fortran/examples-4/simd-2.f90   -O0  execution test
> >> PASS: libgomp.fortran/examples-4/simd-2.f90   -O1  (test for excess errors)
> >> PASS: libgomp.fortran/examples-4/simd-2.f90   -O1  execution test
> >> PASS: libgomp.fortran/examples-4/simd-2.f90   -O2  (test for excess errors)
> >> PASS: libgomp.fortran/examples-4/simd-2.f90   -O2  execution test
> >> PASS: libgomp.fortran/examples-4/simd-2.f90   -O3 -fomit-frame-pointer
> >> -funroll-loops -fpeel-loops -ftracer -finline-functions  (test for
> >> excess errors)
> >> PASS: libgomp.fortran/examples-4/simd-2.f90   -O3 -fomit-frame-pointer
> >> -funroll-loops -fpeel-loops -ftracer -finline-functions  execution
> >> test
> >> PASS: libgomp.fortran/examples-4/simd-2.f90   -O3 -g  (test for excess errors)
> >> PASS: libgomp.fortran/examples-4/simd-2.f90   -O3 -g  execution test
> >> PASS: libgomp.fortran/examples-4/simd-2.f90   -Os  (test for excess errors)
> >> PASS: libgomp.fortran/examples-4/simd-2.f90   -Os  execution test
> >>
> >> I used HASWELL machine for it since test requires target avx.
> >
> > It fails everywhere for me, without offloading configured, both 32-bit and 64-bit.
> > $ /home/jakub/src/gcc/obj20/gcc/xgcc -B/home/jakub/src/gcc/obj20/gcc/ ../../../../libgomp/testsuite/libgomp.fortran/examples-4/simd-2.f90   -B/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp/ -B/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp/.libs -I/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp -I../../../../libgomp/testsuite/../../include -I../../../../libgomp/testsuite/.. -fmessage-length=0 -fno-diagnostics-show-caret -Wno-hsa -fdiagnostics-color=never -fopenmp -B/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp/../libquadmath/.libs/   -O2  -msse2 -mavx -B/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp/../libgfortran/.libs -fintrinsic-modules-path=/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp   -L/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp/.libs -L/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp/../libquadmath/.libs/ -L/home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/./libgomp/../libgfortran/.libs -lgfortran -lm  -o ./simd-2.exe -Wl,-rpath,../.libs/ -march=haswell
> > $ ./simd-2.exe
> >
> > Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
> >
> > Backtrace for this error:
> > #0  0x7F7548CDBD58
> > #1  0x7F7548CDAEE0
> > #2  0x3405234A4F
> > #3  0x400849 in __simd2_mod_MOD_work
> > #4  0x4008D4 in MAIN__ at simd-2.f90:?
> > Segmentation fault (core dumped)
> >
> > With/without -march=haswell, -mtune=haswell etc.
> >
> >         Jakub
Jakub Jelinek June 30, 2016, 2:28 p.m. UTC | #2
On Thu, Jun 30, 2016 at 04:25:16PM +0200, Thomas Schwinge wrote:
> Hi!
> 
> On Thu, 30 Jun 2016 16:48:25 +0300, Yuri Rumyantsev <ysrumyan@gmail.com> wrote:
> > Thanks for your help.
> > Could you please look at the following simple patch which cures
> > regression - we need to nullify loop safelen  field in
> > adjust_simduid_builtins:
> > 
> > diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
> > index 2669813..f70380c 100644
> > --- a/gcc/tree-vectorizer.c
> > +++ b/gcc/tree-vectorizer.c
> > @@ -204,6 +204,10 @@ adjust_simduid_builtins (hash_table<simduid_to_vf> *htab)
> >           gcc_assert (TREE_CODE (arg) == SSA_NAME);
> >           simduid_to_vf *p = NULL, data;
> >           data.simduid = DECL_UID (SSA_NAME_VAR (arg));
> > +         /* Need to nullify safelen fielf of loop since it's vale is not
> > +            valid after transformation.  */

s/fielf/field/
s/vale/value/

> > +         if (bb->loop_father && bb->loop_father->safelen > 0)
> > +           bb->loop_father->safelen = 0;
> >           if (htab)
> >             {
> >               p = htab->find (&data);

	Jakub
diff mbox

Patch

diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
index 2669813..f70380c 100644
--- a/gcc/tree-vectorizer.c
+++ b/gcc/tree-vectorizer.c
@@ -204,6 +204,10 @@  adjust_simduid_builtins (hash_table<simduid_to_vf> *htab)
          gcc_assert (TREE_CODE (arg) == SSA_NAME);
          simduid_to_vf *p = NULL, data;
          data.simduid = DECL_UID (SSA_NAME_VAR (arg));
+         /* Need to nullify safelen fielf of loop since it's vale is not
+            valid after transformation.  */
+         if (bb->loop_father && bb->loop_father->safelen > 0)
+           bb->loop_father->safelen = 0;
          if (htab)
            {
              p = htab->find (&data);