[llvm] r316980 - [CGP] Fix the detection of trivial case for addressing mode

Serguei Katkov via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 31 00:01:35 PDT 2017


Author: skatkov
Date: Tue Oct 31 00:01:35 2017
New Revision: 316980

URL: http://llvm.org/viewvc/llvm-project?rev=316980&view=rev
Log:
[CGP] Fix the detection of trivial case for addressing mode

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

Modified:
    llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp

Modified: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp?rev=316980&r1=316979&r2=316980&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Tue Oct 31 00:01:35 2017
@@ -2751,17 +2751,16 @@ struct ExtAddrMode : public TargetLoweri
       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
+  // the only populated 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;
   }
 };
 




More information about the llvm-commits mailing list