Skip to content

Failure to exploit assume to eliminate use of load #42503

@preames

Description

@preames
Bugzilla Link 43158
Version trunk
OS Linux

Extended Description

Test case:
define i32 @​test(i32* %p, i32 %v) {
%load = load i32, i32* %p
%c = icmp eq i32 %load, %v
call void @​llvm.assume(i1 %c)
ret i32 %load
}

define i32 @​reverse(i32* %p, i32 %v) {
%load = load i32, i32* %p
%c = icmp eq i32 %load, %v
call void @​llvm.assume(i1 %c)
ret i32 %v
}

declare void @​llvm.assume(i1)

Both of these examples are stable under O3; we really should be canonicalizing to one or the other. In this particular example, reverse is the better of the two, but a general heuristic requires more thought.

GVN's propagateEquality has a "prefer early valno" heuristic which appears reasonable. GVN has a separate constant replacement in operands heuristic which also seems reasonable. I suspect these two need to be unified into something of a broader scope.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions