Skip to content

[Loop Vectorizer] Loop Vectorized with Gather Instead of Load Due to SUB => XOR Transformation #88239

@mmarjieh

Description

@mmarjieh

Starting from Clang 18, I get a masked_gather instead of regular load in vectorizer.

Reproducer:
Top of Trunk Clang:
https://godbolt.org/z/aj91K1eaf
See LoopVectorize debug prints:

LAA: Bad stride - Not an AddRecExpr pointer %arrayidx = getelementptr inbounds i32, ptr %a1, i64 %idxprom, !dbg !26 SCEV: ((4 * %idxprom) + %a1)

Clang 17:
https://godbolt.org/z/Y9W56Wds5

I believe that the issue is happening due to instcombine transforming SUB -> XOR. Does it load unscevable pattern?

Metadata

Metadata

Assignees

No one assigned

    Labels

    llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions