Skip to content

[CIR] Difference while lowering in GEP instruction #151173

@Andres-Salamanca

Description

@Andres-Salamanca

While reviewing the IR generated for this PR: #150687, we noticed that the GEP instruction is using pointer arithmetic on an i8:

%val = load i16, ptr getelementptr inbounds nuw (i8, ptr ..., i64 2), align 2

Instead of using the structure type as in classic codegen:

%val = load i16, ptr getelementptr inbounds nuw (%struct.S, ptr ..., i32 0, i32 1), align 2

Although both forms are semantically equivalent, the structure-based GEP is more readable and more reflective of the original source structure. It would be good to track this behavior and evaluate whether it should be aligned with classic codegen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClangIRAnything related to the ClangIR project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions