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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu May 22 03:02:24 PDT 2025


arsenm wrote:

> I tried doing this in InstCombine and the pass fail to reach a fixed point state and the pass is trying to merge back the two constants in to one.

It would be better to review this attempt


 This is one of the reasons why I chose to do it SeparateConstOffset pass.
> 
> Sample IR code:
> 
> %155 = or disjoint i32 %153, %154 %156 = getelementptr inbounds nuw half, ptr addrspace(3) @global_smem, i32 %155 %157 = xor i32 %155, 32 %158 = getelementptr inbounds nuw half, ptr addrspace(3) @global_smem, i32 %157 %159 = or disjoint i32 %155, 2048 %160 = getelementptr inbounds nuw half, ptr addrspace(3) @global_smem, i32 %159 %161 = xor i32 %155, 2080 %162 = getelementptr inbounds nuw half, ptr addrspace(3) @global_smem, i32 %161 %163 = or disjoint i32 %155, 4096 %164 = getelementptr inbounds nuw half, ptr addrspace(3) @global_smem, i32 %163 %165 = xor i32 %155, 4128 %166 = getelementptr inbounds nuw half, ptr addrspace(3) @global_smem, i32 %165 %167 = or disjoint i32 %155, 6144 %168 = getelementptr inbounds nuw half, ptr addrspace(3) @global_smem, i32 %167 %169 = xor i32 %155, 6176 %170 = getelementptr inbounds nuw half, ptr addrspace(3) @global_smem, i32 %169 %171 = or disjoint i32 %155, 8192 %172 = getelementptr inbounds nuw half, ptr addrspace(3) @global_smem, i32 %171 %173 = xor i32 %155, 8224 %174 = getelementptr inbounds nuw half, ptr addrspace(3) @global_smem, i32 %173


Samples that are compilable are always more helpful, this is just a fragment I can't run experiments with 


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


More information about the llvm-commits mailing list