[llvm-commits] PATCH: custom lowering of x86 dec instruction

Peter Cooper peter_cooper at apple.com
Mon Nov 14 11:42:35 PST 2011


Thanks for the comments Evan.  I'll apply the changes you suggested.

I have an idea for a tablegen fix but it would involve adding a new keyword so for example instead of doing "implicit EFLAGS" you could do "transferrable EFLAGS" which means anything that reads EFLAGS from the nodes in the matched tree would now read them from the new node.

However, there's then issues with identifying which node in the pattern had the transferrable EFLAGS and ensuring it can't be applied to cases which define multiple result nodes, but yeah, it could be done.

Pete

On Nov 14, 2011, at 11:08 AM, Evan Cheng wrote:

> 
> On Nov 11, 2011, at 5:59 PM, Peter Cooper wrote:
> 
>> Hi
>> 
>> Please review the attached patch to custom lower a load->dec->store sequence for 64-bit integers on x86.
>> 
>> This is required because tablegen currently doesn't have a way to specify that a store pattern (DEC64m in this case) sets the EFLAGS register with a value that is usable by anything reading EFLAGS from the add -1 in the pattern.  
>> 
>> I've also changed code in EmitTest to allow stores to read from the EFLAGS setting instruction as they won't clobber the flags but this then allows EmitTest to avoid generating an explicit compare instruction.
> 
> Bummer. Do you have any idea how much effort it would take to implement this?
> 
> +    //OPC_CheckPredicate, 1, // Predicate_nontemporalstore
> +    if (StoreNode->isNonTemporal())
> +      break;
> +
> +    LoadSDNode *LoadNode = cast<LoadSDNode>(Chain.getNode());
> +    if (LoadNode->getOperand(1) != Address ||
> +        LoadNode->getOperand(2) != Undef)
> +      break;
> +
> +    //OPC_CheckPredicate, 2, // Predicate_unindexedload
> +    if (LoadNode->getAddressingMode() != ISD::UNINDEXED)
> +      break;
> +
> +    // OPC_CheckPredicate, 3, // Predicate_load
> +    if (LoadNode->getExtensionType() != ISD::NON_EXTLOAD)
> +      break;
> +
> +    //OPC_CheckPredicate, 4, // Predicate_unindexedstore
> +    if (StoreNode->getAddressingMode() != ISD::UNINDEXED)
> +      break;
> +
> +    //OPC_CheckPredicate, 5, // Predicate_store
> +    if (StoreNode->isTruncatingStore())
> +      break;
> 
> These can be replaced by checks for ISD::isNormalLoad() and ISD::isNormalStore().
> 
> +    SDValue ReadsFromStoreChain(StoreNode, 0);
> +    SDValue ReadsFromDecChain(Result, 1);
> +    
> +    ReplaceUses(ReadsFromStoreChain, ReadsFromDecChain);
> +    
> +    SDValue ReadsFromOldDecEFLAGS(StoredVal.getNode(), 1);
> +    SDValue ReadsFromNewDecEFLAGS(Result, 0);
> +    
> +    ReplaceUses(ReadsFromOldDecEFLAGS, ReadsFromNewDecEFLAGS);
> 
> These can be simplified. Something like:
> ReplaceUses(SDValue(StoreNode, 0), SDValue(Result, 1));
> 
> Evan
> 
>> 
>> Thanks,
>> Pete
>> 
>> <6172640.patch>_______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 




More information about the llvm-commits mailing list