[Bug rtl-optimization/105744] [11/12/13 Regression] wrong code with -fexpensive-optimizations -flive-range-shrinkage on powerpc64le-unknown-linux-gnu

zsojka at seznam dot cz gcc-bugzilla@gcc.gnu.org
Fri May 27 08:09:05 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105744

--- Comment #4 from Zdenek Sojka <zsojka at seznam dot cz> ---
(In reply to Kewen Lin from comment #3)
> Hi Zdenek,
> 
> Could you please double check the strncpy implementation on your side? and
> help to file one glibc issue if so.
> 
> One further reduced test case:
> 
> #define N 3
> char a[N];
> char c[N];
> 
> int
> main (void)
> {
>   asm volatile("xxspltib 18, 0xf" : : :"vs18");
>   __builtin_strncpy (c, a, N);
>   if (c[0] || c[1])
>     __builtin_abort ();
>   return 0;
> }

Hello Kewen,

thank you for the simple testcase. I can confirm it fails for me, and I am
using the problematic strncpy implementation:

...
   0x0000000010022f10 <+16>:      lbz     r0,0(r4)
   0x0000000010022f14 <+20>:      stb     r0,0(r3)
   0x0000000010022f18 <+24>:      addi    r11,r3,1
   0x0000000010022f1c <+28>:      addi    r5,r5,-1
   0x0000000010022f20 <+32>:      vspltisb v18,0
...
   0x000000001002319c <+668>:     rldicr  r10,r5,56,7
   0x00000000100231a0 <+672>:     stxvl   vs18,r11,r10
   0x00000000100231a4 <+676>:     blr

The code was added to the glibc tree only 18 months ago, so it might explain
why this wasn't triggered before.

I will open a glibc PR for this.

Many thanks,
Zdenek


More information about the Gcc-bugs mailing list