[llvm] 2362813 - [ConstraintElim] Treat ConstantPointerNull as constant offset 0.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 22 12:04:25 PST 2023


Author: Florian Hahn
Date: 2023-11-22T20:03:04Z
New Revision: 23628137ea9e7a2942d6a691ea74a7697564e65b

URL: https://github.com/llvm/llvm-project/commit/23628137ea9e7a2942d6a691ea74a7697564e65b
DIFF: https://github.com/llvm/llvm-project/commit/23628137ea9e7a2942d6a691ea74a7697564e65b.diff

LOG: [ConstraintElim] Treat ConstantPointerNull as constant offset 0.

Treat ConstantPointerNull (null) as constant offset 0 in the constraint
instead of a variable. This slightly reduces the number of variables. I
was not able to find a test case where this actually caused any changes.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/ConstraintElimination.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 7aadd810c1da387..2c83c4ad452fffa 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -455,6 +455,9 @@ static Decomposition decompose(Value *V,
   if (Ty->isPointerTy() && !IsSigned) {
     if (auto *GEP = dyn_cast<GEPOperator>(V))
       return decomposeGEP(*GEP, Preconditions, IsSigned, DL);
+    if (isa<ConstantPointerNull>(V))
+      return int64_t(0);
+
     return V;
   }
 


        


More information about the llvm-commits mailing list