[llvm] [SeparateConstOffsetFromGEP] Decompose constant xor operand if possible (PR #135788)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Thu May 22 02:43:19 PDT 2025
================
@@ -1162,6 +1202,165 @@ bool SeparateConstOffsetFromGEP::splitGEP(GetElementPtrInst *GEP) {
return true;
}
+// Helper function to check if an instruction has at least one GEP user
+bool XorToOrDisjointTransformer::hasGEPUser(const Value *V) {
+ for (const User *U : V->users()) {
+ if (isa<GetElementPtrInst>(U)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool XorToOrDisjointTransformer::dominatesAllXors(
+ BinaryOperator *BaseXor, const XorOpList &XorsInGroup) {
+ for (const auto &XorEntry : XorsInGroup) {
+ BinaryOperator *XorInst = XorEntry.first;
+ if (XorInst != BaseXor && !DT.dominates(BaseXor, XorInst)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool XorToOrDisjointTransformer::processXorGroup(Instruction *OriginalBaseInst,
+ XorOpList &XorsInGroup) {
+ bool Changed = false;
+ if (XorsInGroup.size() <= 1)
+ return false;
+
+ // Sort XorsInGroup by the constant offset value in increasing order.
+ llvm::sort(
+ XorsInGroup.begin(), XorsInGroup.end(),
----------------
jayfoad wrote:
I thought the point of `llvm::sort` was that you can pass in a range instead of begin and end.
https://github.com/llvm/llvm-project/pull/135788
More information about the llvm-commits
mailing list