llvm-project/llvm/test/Transforms/GVN/load-dead-block.ll
Nikita Popov 3fedaf2a52 [GVN] Don't explicitly materialize undefs from dead blocks
When materializing an available load value, do not explicitly
materialize the undef values from dead blocks. Doing so will
will force creation of a phi with an undef operand, even if there
is a dominating definition. The phi will be folded away on
subsequent GVN iterations, but by then we may have already
poisoned MDA cache slots.

Simply don't register these values in the first place, and let
SSAUpdater do its thing.
2021-03-06 23:46:24 +01:00

37 lines
1020 B
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -gvn < %s | FileCheck %s
define i64 @test(i64** noalias %p, i64* noalias %q) {
; CHECK-LABEL: @test(
; CHECK-NEXT: entry:
; CHECK-NEXT: store i64* [[Q:%.*]], i64** [[P:%.*]], align 8
; CHECK-NEXT: br i1 false, label [[IF:%.*]], label [[MERGE:%.*]]
; CHECK: if:
; CHECK-NEXT: call void @clobber(i64** [[P]])
; CHECK-NEXT: br label [[MERGE]]
; CHECK: merge:
; CHECK-NEXT: store i64 1, i64* [[Q]], align 4
; CHECK-NEXT: [[Q3:%.*]] = getelementptr i64, i64* [[Q]], i64 1
; CHECK-NEXT: store i64 2, i64* [[Q3]], align 4
; CHECK-NEXT: ret i64 1
;
entry:
store i64* %q, i64** %p
br i1 false, label %if, label %merge
if:
call void @clobber(i64** %p)
br label %merge
merge:
%q2 = load i64*, i64** %p
store i64 1, i64* %q2
%v = load i64, i64* %q
%q3 = getelementptr i64, i64* %q, i64 %v
store i64 2, i64* %q3
%v2 = load i64, i64* %q
ret i64 %v2
}
declare void @clobber(i64** %p)