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

Evan Cheng evan.cheng at apple.com
Mon Nov 14 11:08:42 PST 2011


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