* IVopts bug?
@ 2011-11-01 7:42 杜越海
2011-11-01 10:07 ` Richard Guenther
0 siblings, 1 reply; 3+ messages in thread
From: 杜越海 @ 2011-11-01 7:42 UTC (permalink / raw)
To: gcc
[-- Attachment #1: Type: text/plain, Size: 3455 bytes --]
Hi all
I found IVopts rewrite a memory access with a weird iv candidate,
which make it lost its original memory attribute.
a non-local memory access' base pointer was rewrite into a local one,
and it was deleted in pass_cd_dce since
it was recognized as a local memory access.
here is the case i simplified from a decoder source
foo1(unsigned char* pSrcLeft,
unsigned char* pSrcAbove,
unsigned char* pSrcAboveLeft,
unsigned char* pDst,
int dstStep,
int leftStep)
{
signed int x, y, s;
unsigned char p1[5], p2[5], p3;
p1[0] = *pSrcAboveLeft;
p2[0] = p1[0];
p2[1] = pSrcLeft[0];
pSrcLeft += leftStep;
p2[2] = pSrcLeft[0];
pSrcLeft += leftStep;
p2[3] = pSrcLeft[0];
pSrcLeft += leftStep;
p2[4] = pSrcLeft[0];
p1[1] = pSrcAbove[0];
p1[2] = pSrcAbove[1];
p1[3] = pSrcAbove[2];
p1[4] = pSrcAbove[3];
p3 = (unsigned char)(((signed int)p1[1] + (signed int)p2[1] +
(signed int)p1[0]
+(signed int)p1[0] + 2 ) >> 2 );
for( y=0; y<4; y++, pDst += dstStep ) {
for( x=y+1; x<4; x++ ) {
s = ( p1[x-y-1] + p1[x-y] + p1[x-y] + p1[x-y+1] + 2 ) >> 2;
pDst[x] = (unsigned char)s;
}
pDst[y] = p3; -----------------This memory access
}
}
before IVopts
D.6508_65 = pDst_88 + y.6_64;
*D.6508_65 = p3_37;
after IVopts
it was rewrite to
MEM[symbol: p1, index: ivtmp.161_200, offset: 0B] = p3_37 ,
by
candidate 15
depends on 3
var_before ivtmp.161
var_after ivtmp.161
incremented before exit test
type unsigned int
base (unsigned int) pDst_39(D) - (unsigned int) &p1
step (unsigned int) (pretmp.28_118 + 1)
so it still is &p1+ pDst - &p1 + step = pDst + step,
and in pass_cd_dce, is_hidden_global_store () return false for this memory
since it think this stmt only access local array p1.
gcc version r180694
Configured with: /home/croseadu/android/_src/src/gcc-src/configure
--host=i486-linux-gnu --build=i486-linux-gnu
--target=arm-none-linux-gnueabi
--prefix=/home/croseadu/android/_src/install/arm-none-linux-gnueabi
--enable-threads --disable-libmudflap --disable-libssp
--disable-libstdcxx-pch --with-gnu-as --with-gnu-ld
--enable-languages=c,c++ --enable-shared --enable-symvers=gnu
--enable-__cxa_atexit
--with-specs='%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}'
--disable-nls --enable-lto
--with-sysroot=/home/croseadu/android/_src/install/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc
--with-build-sysroot=/home/croseadu/android/_src/install/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc
--with-gmp=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
--with-mpfr=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
--with-ppl=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic
-lm' --with-cloog=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
--enable-cloog-backend=isl
--with-mpc=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
--enable-poison-system-directories --disable-libquadmath --enable-lto
--enable-libgomp
--with-build-time-tools=/home/croseadu/android/_src/install/arm-none-linux-gnueabi/arm-none-linux-gnueabi/bin
--with-cpu=cortex-a8 --with-float=soft
compile flags:
-O3 -mfpu=neon -mfloat-abi=softfp -mvectorize-with-neon-double
need file a bug?
Yuehai Du
[-- Attachment #2: bugReport.c --]
[-- Type: text/x-csrc, Size: 2401 bytes --]
#include <stdarg.h>
#define N 10
__attribute__ ((noinline)) void
foo1(unsigned char* pSrcLeft,
unsigned char* pSrcAbove,
unsigned char* pSrcAboveLeft,
unsigned char* pDst,
int dstStep,
int leftStep)
{
signed int x, y, s;
unsigned char p1[5], p2[5], p3;
p1[0] = *pSrcAboveLeft;
p2[0] = p1[0];
p2[1] = pSrcLeft[0];
pSrcLeft += leftStep;
p2[2] = pSrcLeft[0];
pSrcLeft += leftStep;
p2[3] = pSrcLeft[0];
pSrcLeft += leftStep;
p2[4] = pSrcLeft[0];
p1[1] = pSrcAbove[0];
p1[2] = pSrcAbove[1];
p1[3] = pSrcAbove[2];
p1[4] = pSrcAbove[3];
p3 = (unsigned char)(((signed int)p1[1] + (signed int)p2[1] + (signed int)p1[0]
+(signed int)p1[0] + 2 ) >> 2 );
for( y=0; y<4; y++, pDst += dstStep ) {
for( x=y+1; x<4; x++ ) {
s = ( p1[x-y-1] + p1[x-y] + p1[x-y] + p1[x-y+1] + 2 ) >> 2;
pDst[x] = (unsigned char)s;
}
pDst[y] = p3;
}
}
__attribute__ ((noinline)) void
foo2(unsigned char* pSrcLeft,
unsigned char* pSrcAbove,
unsigned char* pSrcAboveLeft,
unsigned char* pDst,
int dstStep,
int leftStep)
{
signed int x, y, s;
unsigned char p1[5], p2[5], p3;
p1[0] = *pSrcAboveLeft;
p2[0] = p1[0];
p2[1] = pSrcLeft[0];
pSrcLeft += leftStep;
p2[2] = pSrcLeft[0];
pSrcLeft += leftStep;
p2[3] = pSrcLeft[0];
pSrcLeft += leftStep;
p2[4] = pSrcLeft[0];
p1[1] = pSrcAbove[0];
p1[2] = pSrcAbove[1];
p1[3] = pSrcAbove[2];
p1[4] = pSrcAbove[3];
p3 = (unsigned char)(((signed int)p1[1] + (signed int)p2[1] + (signed int)p1[0]
+(signed int)p1[0] + 2 ) >> 2 );
for( y=0; y<4; y++, pDst += dstStep ) {
for( x=y+1; x<4; x++ ) {
s = ( p1[x-y-1] + p1[x-y] + p1[x-y] + p1[x-y+1] + 2 ) >> 2;
pDst[x] = (unsigned char)s;
__asm__ volatile ("");
}
pDst[y] = p3;
}
}
unsigned char pSrcLeft[N];
unsigned char pSrcAbove[N];
unsigned char pSrcAboveLeft[N];
unsigned char pDst1[N];
unsigned char pDst2[N];
int main()
{
int i;
for (i=0; i<N; i++)
{
pSrcLeft[i] = i*2;
pSrcAbove[i] = 200-i;
pSrcAboveLeft[i] = 20+2*i-1;
pDst1[i] = 255;
pDst2[i] = 255;
}
foo1(pSrcLeft, pSrcAbove, pSrcAboveLeft, pDst1, 1,1);
foo2(pSrcLeft, pSrcAbove, pSrcAboveLeft, pDst2, 1,1);
for (i=0; i<N; i++)
{
if (pDst1[i] != pDst2[i])
abort();
}
return 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: IVopts bug?
2011-11-01 7:42 IVopts bug? 杜越海
@ 2011-11-01 10:07 ` Richard Guenther
2011-11-02 5:19 ` Yuehai Du
0 siblings, 1 reply; 3+ messages in thread
From: Richard Guenther @ 2011-11-01 10:07 UTC (permalink / raw)
To: 杜越海; +Cc: gcc
2011/11/1 杜越海 <duyuehai@gmail.com>:
> Hi all
>
> I found IVopts rewrite a memory access with a weird iv candidate,
> which make it lost its original memory attribute.
> a non-local memory access' base pointer was rewrite into a local one,
> and it was deleted in pass_cd_dce since
> it was recognized as a local memory access.
>
> here is the case i simplified from a decoder source
>
> foo1(unsigned char* pSrcLeft,
> unsigned char* pSrcAbove,
> unsigned char* pSrcAboveLeft,
> unsigned char* pDst,
> int dstStep,
> int leftStep)
> {
> signed int x, y, s;
> unsigned char p1[5], p2[5], p3;
>
> p1[0] = *pSrcAboveLeft;
> p2[0] = p1[0];
> p2[1] = pSrcLeft[0];
> pSrcLeft += leftStep;
> p2[2] = pSrcLeft[0];
> pSrcLeft += leftStep;
> p2[3] = pSrcLeft[0];
> pSrcLeft += leftStep;
> p2[4] = pSrcLeft[0];
>
> p1[1] = pSrcAbove[0];
> p1[2] = pSrcAbove[1];
> p1[3] = pSrcAbove[2];
> p1[4] = pSrcAbove[3];
>
> p3 = (unsigned char)(((signed int)p1[1] + (signed int)p2[1] +
> (signed int)p1[0]
> +(signed int)p1[0] + 2 ) >> 2 );
>
> for( y=0; y<4; y++, pDst += dstStep ) {
> for( x=y+1; x<4; x++ ) {
> s = ( p1[x-y-1] + p1[x-y] + p1[x-y] + p1[x-y+1] + 2 ) >> 2;
> pDst[x] = (unsigned char)s;
> }
>
> pDst[y] = p3; -----------------This memory access
> }
> }
>
> before IVopts
>
> D.6508_65 = pDst_88 + y.6_64;
> *D.6508_65 = p3_37;
>
> after IVopts
> it was rewrite to
> MEM[symbol: p1, index: ivtmp.161_200, offset: 0B] = p3_37 ,
>
> by
> candidate 15
> depends on 3
> var_before ivtmp.161
> var_after ivtmp.161
> incremented before exit test
> type unsigned int
> base (unsigned int) pDst_39(D) - (unsigned int) &p1
> step (unsigned int) (pretmp.28_118 + 1)
>
> so it still is &p1+ pDst - &p1 + step = pDst + step,
> and in pass_cd_dce, is_hidden_global_store () return false for this memory
> since it think this stmt only access local array p1.
>
>
>
> gcc version r180694
>
> Configured with: /home/croseadu/android/_src/src/gcc-src/configure
> --host=i486-linux-gnu --build=i486-linux-gnu
> --target=arm-none-linux-gnueabi
> --prefix=/home/croseadu/android/_src/install/arm-none-linux-gnueabi
> --enable-threads --disable-libmudflap --disable-libssp
> --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld
> --enable-languages=c,c++ --enable-shared --enable-symvers=gnu
> --enable-__cxa_atexit
> --with-specs='%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}'
> --disable-nls --enable-lto
> --with-sysroot=/home/croseadu/android/_src/install/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc
> --with-build-sysroot=/home/croseadu/android/_src/install/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc
> --with-gmp=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
> --with-mpfr=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
> --with-ppl=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
> --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic
> -lm' --with-cloog=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
> --enable-cloog-backend=isl
> --with-mpc=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
> --enable-poison-system-directories --disable-libquadmath --enable-lto
> --enable-libgomp
> --with-build-time-tools=/home/croseadu/android/_src/install/arm-none-linux-gnueabi/arm-none-linux-gnueabi/bin
> --with-cpu=cortex-a8 --with-float=soft
>
> compile flags:
> -O3 -mfpu=neon -mfloat-abi=softfp -mvectorize-with-neon-double
>
> need file a bug?
Yes, it definitely should not do this kind of stupid (and invalid) thing.
Richard.
>
> Yuehai Du
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: IVopts bug?
2011-11-01 10:07 ` Richard Guenther
@ 2011-11-02 5:19 ` Yuehai Du
0 siblings, 0 replies; 3+ messages in thread
From: Yuehai Du @ 2011-11-02 5:19 UTC (permalink / raw)
To: Richard Guenther, gcc
2011/11/1 Richard Guenther <richard.guenther@gmail.com>:
> 2011/11/1 杜越海 <duyuehai@gmail.com>:
>> Hi all
>>
>> I found IVopts rewrite a memory access with a weird iv candidate,
>> which make it lost its original memory attribute.
>> a non-local memory access' base pointer was rewrite into a local one,
>> and it was deleted in pass_cd_dce since
>> it was recognized as a local memory access.
>>
>> here is the case i simplified from a decoder source
>>
>> foo1(unsigned char* pSrcLeft,
>> unsigned char* pSrcAbove,
>> unsigned char* pSrcAboveLeft,
>> unsigned char* pDst,
>> int dstStep,
>> int leftStep)
>> {
>> signed int x, y, s;
>> unsigned char p1[5], p2[5], p3;
>>
>> p1[0] = *pSrcAboveLeft;
>> p2[0] = p1[0];
>> p2[1] = pSrcLeft[0];
>> pSrcLeft += leftStep;
>> p2[2] = pSrcLeft[0];
>> pSrcLeft += leftStep;
>> p2[3] = pSrcLeft[0];
>> pSrcLeft += leftStep;
>> p2[4] = pSrcLeft[0];
>>
>> p1[1] = pSrcAbove[0];
>> p1[2] = pSrcAbove[1];
>> p1[3] = pSrcAbove[2];
>> p1[4] = pSrcAbove[3];
>>
>> p3 = (unsigned char)(((signed int)p1[1] + (signed int)p2[1] +
>> (signed int)p1[0]
>> +(signed int)p1[0] + 2 ) >> 2 );
>>
>> for( y=0; y<4; y++, pDst += dstStep ) {
>> for( x=y+1; x<4; x++ ) {
>> s = ( p1[x-y-1] + p1[x-y] + p1[x-y] + p1[x-y+1] + 2 ) >> 2;
>> pDst[x] = (unsigned char)s;
>> }
>>
>> pDst[y] = p3; -----------------This memory access
>> }
>> }
>>
>> before IVopts
>>
>> D.6508_65 = pDst_88 + y.6_64;
>> *D.6508_65 = p3_37;
>>
>> after IVopts
>> it was rewrite to
>> MEM[symbol: p1, index: ivtmp.161_200, offset: 0B] = p3_37 ,
>>
>> by
>> candidate 15
>> depends on 3
>> var_before ivtmp.161
>> var_after ivtmp.161
>> incremented before exit test
>> type unsigned int
>> base (unsigned int) pDst_39(D) - (unsigned int) &p1
>> step (unsigned int) (pretmp.28_118 + 1)
>>
>> so it still is &p1+ pDst - &p1 + step = pDst + step,
>> and in pass_cd_dce, is_hidden_global_store () return false for this memory
>> since it think this stmt only access local array p1.
>>
>>
>>
>> gcc version r180694
>>
>> Configured with: /home/croseadu/android/_src/src/gcc-src/configure
>> --host=i486-linux-gnu --build=i486-linux-gnu
>> --target=arm-none-linux-gnueabi
>> --prefix=/home/croseadu/android/_src/install/arm-none-linux-gnueabi
>> --enable-threads --disable-libmudflap --disable-libssp
>> --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld
>> --enable-languages=c,c++ --enable-shared --enable-symvers=gnu
>> --enable-__cxa_atexit
>> --with-specs='%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}'
>> --disable-nls --enable-lto
>> --with-sysroot=/home/croseadu/android/_src/install/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc
>> --with-build-sysroot=/home/croseadu/android/_src/install/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc
>> --with-gmp=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
>> --with-mpfr=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
>> --with-ppl=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
>> --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic
>> -lm' --with-cloog=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
>> --enable-cloog-backend=isl
>> --with-mpc=/home/croseadu/android/_src/objs/arm-none-linux-gnueabi/obj/host-libs-/usr
>> --enable-poison-system-directories --disable-libquadmath --enable-lto
>> --enable-libgomp
>> --with-build-time-tools=/home/croseadu/android/_src/install/arm-none-linux-gnueabi/arm-none-linux-gnueabi/bin
>> --with-cpu=cortex-a8 --with-float=soft
>>
>> compile flags:
>> -O3 -mfpu=neon -mfloat-abi=softfp -mvectorize-with-neon-double
>>
>> need file a bug?
>
> Yes, it definitely should not do this kind of stupid (and invalid) thing.
>
> Richard.
>
>>
>> Yuehai Du
>>
>
file a bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50955, Could
someboy help me to fix this PR? Thank you very much.
Yuehai Du
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-02 5:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-01 7:42 IVopts bug? 杜越海
2011-11-01 10:07 ` Richard Guenther
2011-11-02 5:19 ` Yuehai Du
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).