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

--- Comment #11 from Segher Boessenkool <segher at gcc dot gnu.org> ---
In the 64-bit Power ABIs, an int is passed as a sign-extended 64-bit register.
Take this trivial example:

int f(int x) { return x*x; }

which compiles to (on powerpc64-linux, BE):

.L.f:
        mullw 3,3,3      # 6    [c=8 l=4]  mulsi3/0
        extsw 3,3        # 12   [c=4 l=4]  extendsidi2/1
        blr              # 19   [c=4 l=4]  simple_return

Right before combine it is

  2: r122:DI=%3:DI
  6: r123:SI=r122:DI#4*r122:DI#4
  7: r124:DI=sign_extend(r123:SI)
 12: %3:DI=r124:DI
 13: use %3:DI

(note %3, the argument, is DI; and r122, the pseudo the argument is copied to,
is DI as well).

So r122 could be made SImode here, instead, because it only ever is used as SI.
But it doesn't hurt here.  And knowing it has the proper value in DImode
already
helps optimisation, too (as in  long f(int x) { return (long)x + 42; }  ).

What is different in your example it there is a *second* assignment to r160
there, where that second assignment has a sign extension, that then isn't
optimised away.

Reply via email to