[PATCH] D16090: [SelectionDAG] Fold more offsets into GlobalAddresses

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 19 21:51:04 PST 2016


arsenm added a subscriber: arsenm.

================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:397
@@ +396,3 @@
+    /// Match "(X shl/srl V1) & V2" where V2 may not be present.
+    bool MatchRotateHalf(SDValue Op, SDValue &Shift, SDValue &Mask);
+
----------------
Why does this need to be added here? I don't see a new use of this

================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:782-783
@@ +781,4 @@
+  if (GlobalAddressSDNode *GA = dyn_cast<GlobalAddressSDNode>(N))
+    if (TLI.isOffsetFoldingLegal(GA) &&
+        GA->getOpcode() == ISD::GlobalAddress)
+      return GA;
----------------
The order of these checks should be swapped

================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAG.cpp:3278-3281
@@ +3277,6 @@
+                                       const SDNode *N2) {
+  if (!TLI->isOffsetFoldingLegal(GA))
+    return SDValue();
+  if (GA->getOpcode() != ISD::GlobalAddress)
+    return SDValue();
+  const ConstantSDNode *Cst2 = dyn_cast<ConstantSDNode>(N2);
----------------
Ditto

================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAG.cpp:3285
@@ +3284,3 @@
+    return SDValue();
+  uint64_t Offset = Cst2->getSExtValue();
+  switch (Opcode) {
----------------
This should be int64_t, since you use getSExtValue and negate it below 


Repository:
  rL LLVM

http://reviews.llvm.org/D16090





More information about the llvm-commits mailing list