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]

Re: Combiner fixes


On Tue, Aug 3, 2010 at 7:46 AM, Bernd Schmidt <bernds@codesourcery.com> wrote:
> On 08/03/2010 09:24 AM, Paolo Bonzini wrote:
>> On 08/02/2010 10:37 PM, Bernd Schmidt wrote:
>>> + ? ? ?if (GET_CODE (op0) == NEG && CONST_INT_P (trueop1))
>>> + ? ?return simplify_gen_binary (MULT, mode, XEXP (op0, 0),
>>> + ? ? ? ? ? ? ? ? ? ?simplify_gen_unary (NEG, mode, op1, mode));
>>
>> Why not go one step further and try it on all operands:
>>
>> ? if (GET_CODE (op0) == NEG)
>> ? ? {
>> ? ? ? rtx temp = simplify_unary (NEG, mode, op1, mode);
>> ? ? ? if (temp)
>> ? ? ? ? return simplify_gen_binary (MULT, mode, XEXP (op0, 0), temp);
>> ? ? }
>> ? if (GET_CODE (op1) == NEG)
>> ? ? {
>> ? ? ? rtx temp = simplify_unary (NEG, mode, op0, mode);
>> ? ? ? if (temp)
>> ? ? ? ? return simplify_gen_binary (MULT, mode, temp, XEXP (op1, 0));
>> ? ? }
>
> Done (slight typo in the above, needs simplify_unary_operation), and
> also implemented the opposite transformation in combine:
> ?(minus x (mult y -12345))
> becomes
> ?(plus (mult y 12345) x)
>
> I've now also looked at code generation on i686, where it also seems to
> help occasionally:
> - ? ? ? imull ? $-12, 4(%ecx), %edx
> - ? ? ? movl ? ?$4, %eax
> - ? ? ? subl ? ?%edx, %eax
> + ? ? ? imull ? $12, 4(%ecx), %eax
> + ? ? ? addl ? ?$4, %eax
> =========
> - ? ? ? sall ? ?$5, %eax
> - ? ? ? negl ? ?%eax
> - ? ? ? imull ? $-2, %eax, %eax
> + ? ? ? sall ? ?$6, %eax
>
> There's a single counterexample I found, in 20040709-2.c:
> - ? ? ? imull ? $-1029531031, %ecx, %ebp
> - ? ? ? subl ? ?$740551042, %ebp
> + ? ? ? imull ? $1103515245, %ecx, %ebp
> + ? ? ? addl ? ?$12345, %ebp
> + ? ? ? imull ? $1103515245, %ebp, %ebp
> + ? ? ? addl ? ?$12345, %ebp
>
> where an intermediate (minus (const) (mult x const)) is not recognized
> as a valid pattern in combine, which then prevents later
> transformations. ?I think it's one of these cases where combine could
> benefit from looking at 4 insns.
>
> Bootstrapped and regression tested on i686-linux. ?In the ARM tests,
> with the previous patch I saw an intermittent segfault on one testcase,
> which wasn't reproducible when running the compiler manually, and has
> gone away with the new version (tests still running). ?I think it's
> unrelated.
>
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45182

-- 
H.J.


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