[PATCH] D38783: [CGP] Fix the detection of trivial case for addressing mode

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 10 22:24:20 PDT 2017


skatkov created this revision.

The address can be presented as a bitcast of baseReg.
In this case it is still trivial but OriginalValue != baseReg.


https://reviews.llvm.org/D38783

Files:
  lib/CodeGen/CodeGenPrepare.cpp


Index: lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- lib/CodeGen/CodeGenPrepare.cpp
+++ lib/CodeGen/CodeGenPrepare.cpp
@@ -2727,17 +2727,15 @@
       return static_cast<FieldName>(Result);
   }
 
-  // AddrModes with a base reg or gv where the reg/gv is just the original
-  // value are trivial.
+  // AddrModes with a baseReg or gv where the reg/gv is alone field are trivial.
   bool isTrivial() {
-    bool Trivial = (BaseGV && BaseGV == OriginalValue) ||
-      (BaseReg && BaseReg == OriginalValue);
-    // If the AddrMode is trivial it shouldn't have an offset or be scaled.
-    if (Trivial) {
-      assert(BaseOffs == 0);
-      assert(Scale == 0);
-    }
-    return Trivial;
+    if (BaseGV && !BaseOffs && !Scale && !BaseReg)
+      return true;
+
+    if (!BaseGV && !BaseOffs && !Scale && BaseReg)
+      return true;
+
+    return false;
   }
 };
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38783.118541.patch
Type: text/x-patch
Size: 923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171011/eb90efd2/attachment.bin>


More information about the llvm-commits mailing list