[llvm] [SeparateConstOffsetFromGEP] Decompose constant xor operand if possible (PR #135788)

Juan Manuel Martinez CaamaƱo via llvm-commits llvm-commits at lists.llvm.org
Thu May 22 02:02:00 PDT 2025


================
@@ -1181,6 +1380,11 @@ bool SeparateConstOffsetFromGEP::run(Function &F) {
 
   DL = &F.getDataLayout();
   bool Changed = false;
+
+  // Decompose xor in to "or disjoint" if possible.
+  XorToOrDisjointTransformer XorTransformer(F, *DT, *DL);
+  Changed |= XorTransformer.run();
+
   for (BasicBlock &B : F) {
     if (!DT->isReachableFromEntry(&B))
----------------
jmmartinez wrote:

The PR looks good to me, but I have one last remark that I've just realized.

This pass defends itself from potentially unreachable blocks. I do not know in which context does that happen, but if it happens on real code this could result in broken compilation.

Could you confirm if this can actually happen? If it doesn't, we can merge this and remove the `isReachableFromEntry` check in another PR.

https://github.com/llvm/llvm-project/pull/135788


More information about the llvm-commits mailing list