[llvm] b8a5a01 - [InstCombine] Use pointer alignment in SimplifyDemandedBits

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 04:57:02 PST 2023


Author: Nikita Popov
Date: 2023-11-30T13:56:42+01:00
New Revision: b8a5a015d12c698a3254898c94d0adffe0724fa8

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

LOG: [InstCombine] Use pointer alignment in SimplifyDemandedBits

For parity with computeKnownBits(). This came up when adding a
consistency assertion.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index d1eab4c05287244..5e7ed7e165eceb1 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -1022,6 +1022,11 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
   }
   }
 
+  if (V->getType()->isPointerTy()) {
+    Align Alignment = V->getPointerAlignment(DL);
+    Known.Zero.setLowBits(Log2(Alignment));
+  }
+
   // If the client is only demanding bits that we know, return the known
   // constant. We can't directly simplify pointers as a constant because of
   // pointer provenance.


        


More information about the llvm-commits mailing list