[PATCH] [Multiprecision Arithmetic Optimization] Teach SelectionDAG how to promote the integer carry result of {add, sub}{c, e} to a larger integer type.

Duncan Sands duncan.sands at gmail.com
Tue May 21 12:12:46 PDT 2013


Hi Michael,

On 17/05/13 23:33, Michael Gottesman wrote:
> Hows this look Duncan/Sean?

thanks for adding the ResNo == 0 case, but I don't think it is correct.
That's because you continue to return an ADDC code, yet because you zero
extended the add operands there is no reason why the extended operands
should overflow (set the carry flag) exactly when the original operation
would.

Actually, isn't ADDC really exactly the same as UADDO?  If so, how about
eliminating the ADDC in favour of UADDO?  In any case, there's already
promotion logic for UADDO, DAGTypeLegalizer::PromoteIntRes_UADDSUBO, so
maybe you could take a look.

I didn't think about ADDE but at a glance it has the same flaw.

Ciao, Duncan.

>
>
>
>
> Michael
>
> On May 16, 2013, at 10:41 AM, Michael Gottesman <mgottesman at apple.com
> <mailto:mgottesman at apple.com>> wrote:
>
>> I am trying to be incremental and did not have a need for such lowering. On
>> the other hand if you want I can implement that in this patch. Just state your
>> preference = ).
>>
>> Michael
>>
>> On May 16, 2013, at 1:34 AM, Duncan Sands <duncan.sands at gmail.com
>> <mailto:duncan.sands at gmail.com>> wrote:
>>
>>> Hi Michael,
>>>
>>> On 15/05/13 19:37, Michael Gottesman wrote:
>>>> The attached patch teaches selection DAG how to promote the integer carry
>>>> result of an {add,sub}{c,e} node to a larger integer type. It is a part of a
>>>> larger set of patches that I will be committing over the next little bit to
>>>> enable the optimization of uaddo/usubo chains.
>>>>
>>>> Please Review,
>>>> Michael
>>>
>>> +SDValue DAGTypeLegalizer::PromoteIntRes_ADDSUBC(SDNode *N, unsigned ResNo) {
>>> +  if (ResNo == 1)
>>> +    return PromoteIntRes_Overflow(N);
>>> +  return SDValue();
>>> +}
>>> +
>>> +SDValue DAGTypeLegalizer::PromoteIntRes_ADDSUBE(SDNode *N, unsigned ResNo) {
>>> +  if (ResNo == 1)
>>> +    return PromoteIntRes_Overflow(N);
>>> +  return SDValue();
>>> +}
>>>
>>> why do you return SDValue() if ResNo != 1 ?  Shouldn't you either assert or
>>> promote the value?
>>>
>>> Ciao, Duncan.
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu <mailto:llvm-commits at cs.uiuc.edu>
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu <mailto:llvm-commits at cs.uiuc.edu>
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list