Hi, All

Can LNO gatekeeper help review this fix?

This bug happens in -m32 on x8664 linux.
Attached is the test case and patch.
command line is
opencc -O3 unsigned_loop_end.c -INLINE:ne=foo:ne=init:ne=check
-OPT:unroll_times_max=1 -m32

The bug happens when vectorization is happend on following loop.
   int a[100]
   int start;
   unsigned i, end;
   for( i = start; i < end; i++) {
     a[i] = a[i+1];
   }
with -m64 unsigned comparison is transformed to signed comparison in
STD_Canonicalize_Upper_Bound.
with -m32 unsigned comparison is kept in LNO.

Simd_Finalize_Loops will update loop_end align to vecotrize factor (vect)
i <= start + (((end - start + 1) / vect) * vect) -1
suppose start is 0, end is 2, vect is 4, original serial loop is
for( i = 0; i < 2; i++)
after Simd_Finalize_Loops transformation, simd loop becomes
for(i = 0, i <= -1; i++),
This loop will itreate 0xffffffff times.

The fix is change loop end to following form when compraion is unsigned.
i < start + (((end - start + 1) / vect) * vect)


As discussed with Shuxin, we also doubt why SIMD loop's upper need aligned
with vecotrized factor. Can SIMD only update loop's step?
like  for(i = start, i <= end-1; i+= vector_factor)?


Best Regards
Shi, Hui

Attachment: simd.patch
Description: Binary data

Attachment: unsigned_loop_end.c
Description: Binary data

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to