This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch]Simplify SUBREG with operand whose target bits are cleared by AND operation


Hi there,

When compile below case for ARM Thumb-2 target:

long long int
test (unsigned long long int a, unsigned int b)
{
  return (a & 0xFFFFFFFF) * b;
}

I find the GCC function simplify_subreg fails to simplify rtx (subreg:SI
(and:DI (reg/v:DI 115 [ a ]) (const_int 4294967295 [0xffffffff])) 4) to zero
during the fwprop1 pass, considering the fact that the high 32-bit part of
(a & 0xFFFFFFFF) is zero. This leads to some unnecessary multiplications for
high 32-bit part of the result of AND operation. The attached patch is
trying to improve simplify_rtx to handle such case. Other target like x86
seems hasn't such issue because it generates different RTX to handle 64bit
multiplication on a 32bit machine.

Bootstrapped gcc on x86 machine, no problem. Tested with gcc regression test
for x86 and Thumb2, no regression.

Is it OK to stage-1?

BR,
Terry

Attachment: simplify-subreg-with-and-v1.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]