Skip to content

(New)GVN doesn't look through non-constant memcpy #31917

@Keno

Description

@Keno
Bugzilla Link 32570
Version trunk
OS All
CC @hfinkel

Extended Description

E.g. in this example, GVN can't turn this into load a[100]:

declare void @llvm.memcpy.p0i8.p0i8.i64(i8*, i8*, i64, i32, i1)

define double @trivial_memcpy(<200 x double> *%a) {
    %b = alloca <200 x double>
    %acast = bitcast <200 x double> *%a to i8*
    %bcast = bitcast <200 x double> *%b to i8*
    call void @llvm.memcpy.p0i8.p0i8.i64(i8* %bcast, i8* %acast, i64 1600, i32 8, i1 0)
    %innerptr = getelementptr <200 x double>, <200 x double> *%a, i32 0, i32 100
    %inner = load double, double *%innerptr
    ret double %inner
}

Now for this particular example, SROA does do this optimization, but this feels like something that GVN should be able to do as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillallvm:GVNGVN and NewGVN stages (Global value numbering)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions