[llvm] 5b17b32 - [SVE][CodeGen] Replace use of TypeSize comparison operator in CreateStackTemporary

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 21 00:42:15 PDT 2020


Author: David Sherwood
Date: 2020-10-21T08:31:36+01:00
New Revision: 5b17b323a6179d60c58d5048e0679fbbe6782290

URL: https://github.com/llvm/llvm-project/commit/5b17b323a6179d60c58d5048e0679fbbe6782290
DIFF: https://github.com/llvm/llvm-project/commit/5b17b323a6179d60c58d5048e0679fbbe6782290.diff

LOG: [SVE][CodeGen] Replace use of TypeSize comparison operator in CreateStackTemporary

We were previously relying upon the TypeSize comparison operators to
obtain the maximum size of two types, however use of such operators is
being deprecated in favour of making the caller aware that it could
be dealing with scalable vector types. I have changed the code to assert
that the two types have the same scalable property and thus we can
simply take the maximum of the known minimum sizes instead.

Differential Revision: https://reviews.llvm.org/D88563

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 5fe26a6d2abd..b1e2679d86dc 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -2045,7 +2045,14 @@ SDValue SelectionDAG::CreateStackTemporary(EVT VT, unsigned minAlign) {
 }
 
 SDValue SelectionDAG::CreateStackTemporary(EVT VT1, EVT VT2) {
-  TypeSize Bytes = std::max(VT1.getStoreSize(), VT2.getStoreSize());
+  TypeSize VT1Size = VT1.getStoreSize();
+  TypeSize VT2Size = VT2.getStoreSize();
+  assert(VT1Size.isScalable() == VT2Size.isScalable() &&
+         "Don't know how to choose the maximum size when creating a stack "
+         "temporary");
+  TypeSize Bytes =
+      VT1Size.getKnownMinSize() > VT2Size.getKnownMinSize() ? VT1Size : VT2Size;
+
   Type *Ty1 = VT1.getTypeForEVT(*getContext());
   Type *Ty2 = VT2.getTypeForEVT(*getContext());
   const DataLayout &DL = getDataLayout();


        


More information about the llvm-commits mailing list