This adds a new pass for dropping assumes that are unlikely to be useful for further optimization. It works by discarding any assumes whose affected values are one-use (which implies that they are only used by the assume, i.e. ephemeral). This pass currently runs at the start of the module optimization pipeline, that is post-inline and post-link. Before that point, it is more likely for previously "useless" assumes to become useful again, e.g. because an additional user of the value is introduced after inlining + CSE.
36 lines
929 B
LLVM
36 lines
929 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt -O3 -S < %s | FileCheck %s
|
|
; RUN: opt -passes="default<O3>" -S < %s | FileCheck %s
|
|
|
|
define void @PR45682(i32 %x, i32 %y) {
|
|
; CHECK-LABEL: @PR45682(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
entry:
|
|
%x.addr = alloca i32, align 4
|
|
%y.addr = alloca i32, align 4
|
|
store i32 %x, ptr %x.addr, align 4
|
|
store i32 %y, ptr %y.addr, align 4
|
|
%0 = load i32, ptr %y.addr, align 4
|
|
%cmp = icmp sgt i32 %0, 0
|
|
call void @llvm.assume(i1 %cmp)
|
|
%1 = load i32, ptr %y.addr, align 4
|
|
%2 = load i32, ptr %x.addr, align 4
|
|
%add = add nsw i32 %2, %1
|
|
store i32 %add, ptr %x.addr, align 4
|
|
%3 = load i32, ptr %x.addr, align 4
|
|
%cmp1 = icmp eq i32 %3, -2147483648
|
|
br i1 %cmp1, label %if.then, label %if.end
|
|
|
|
if.then:
|
|
call void @v()
|
|
br label %if.end
|
|
|
|
if.end:
|
|
ret void
|
|
}
|
|
|
|
declare void @v()
|
|
declare void @llvm.assume(i1)
|