1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
llvm-mirror/test/Transforms/GVN/pr25440.ll
Dehao Chen eb60ada52c Do not widen load for different variable in GVN.
Summary:
Widening load in GVN is too early because it will block other optimizations like PRE, LICM.

https://llvm.org/bugs/show_bug.cgi?id=29110

The SPECCPU2006 benchmark impact of this patch:

Reference: o2_nopatch
(1): o2_patched

           Benchmark             Base:Reference   (1)  
-------------------------------------------------------
spec/2006/fp/C++/444.namd                  25.2  -0.08%
spec/2006/fp/C++/447.dealII               45.92  +1.05%
spec/2006/fp/C++/450.soplex                41.7  -0.26%
spec/2006/fp/C++/453.povray               35.65  +1.68%
spec/2006/fp/C/433.milc                   23.79  +0.42%
spec/2006/fp/C/470.lbm                    41.88  -1.12%
spec/2006/fp/C/482.sphinx3                47.94  +1.67%
spec/2006/int/C++/471.omnetpp             22.46  -0.36%
spec/2006/int/C++/473.astar               21.19  +0.24%
spec/2006/int/C++/483.xalancbmk           36.09  -0.11%
spec/2006/int/C/400.perlbench             33.28  +1.35%
spec/2006/int/C/401.bzip2                 22.76  -0.04%
spec/2006/int/C/403.gcc                   32.36  +0.12%
spec/2006/int/C/429.mcf                   41.04  -0.41%
spec/2006/int/C/445.gobmk                 26.94  +0.04%
spec/2006/int/C/456.hmmer                  24.5  -0.20%
spec/2006/int/C/458.sjeng                    28  -0.46%
spec/2006/int/C/462.libquantum            55.25  +0.27%
spec/2006/int/C/464.h264ref               45.87  +0.72%

geometric mean                                   +0.23%

For most benchmarks, it's a wash, but we do see stable improvements on some benchmarks, e.g. 447,453,482,400.

Reviewers: davidxl, hfinkel, dberlin, sanjoy, reames

Subscribers: gberry, junbuml

Differential Revision: https://reviews.llvm.org/D24096

llvm-svn: 281074
2016-09-09 18:42:35 +00:00

109 lines
3.7 KiB
LLVM

;RUN: opt -gvn -S < %s | FileCheck %s
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n8:16:32-S64"
target triple = "thumbv7--linux-gnueabi"
%struct.a = type { i16, i16, [1 x %union.a] }
%union.a = type { i32 }
@length = external global [0 x i32], align 4
; Function Attrs: nounwind
define fastcc void @foo(%struct.a* nocapture readonly %x) {
;CHECK-LABEL: foo
entry:
br label %bb0
bb0: ; preds = %land.lhs.true, %entry
;CHECK: bb0:
%x.tr = phi %struct.a* [ %x, %entry ], [ null, %land.lhs.true ]
%code1 = getelementptr inbounds %struct.a, %struct.a* %x.tr, i32 0, i32 0
%0 = load i16, i16* %code1, align 4
; CHECK: load i16, i16*
%conv = zext i16 %0 to i32
switch i32 %conv, label %if.end.50 [
i32 43, label %cleanup
i32 52, label %if.then.5
]
if.then.5: ; preds = %bb0
br i1 undef, label %land.lhs.true, label %if.then.26
land.lhs.true: ; preds = %if.then.5
br i1 undef, label %cleanup, label %bb0
if.then.26: ; preds = %if.then.5
%x.tr.lcssa163 = phi %struct.a* [ %x.tr, %if.then.5 ]
br i1 undef, label %cond.end, label %cond.false
cond.false: ; preds = %if.then.26
; CHECK: cond.false:
; CHECK: load i16
%mode = getelementptr inbounds %struct.a, %struct.a* %x.tr.lcssa163, i32 0, i32 1
%bf.load = load i16, i16* %mode, align 2
%bf.shl = shl i16 %bf.load, 8
br label %cond.end
cond.end: ; preds = %cond.false, %if.then.26
br i1 undef, label %if.then.44, label %cleanup
if.then.44: ; preds = %cond.end
unreachable
if.end.50: ; preds = %bb0
;%CHECK: if.end.50:
%conv.lcssa = phi i32 [ %conv, %bb0 ]
%arrayidx52 = getelementptr inbounds [0 x i32], [0 x i32]* @length, i32 0, i32 %conv.lcssa
%1 = load i32, i32* %arrayidx52, align 4
br i1 undef, label %for.body.57, label %cleanup
for.body.57: ; preds = %if.end.50
%i.2157 = add nsw i32 %1, -1
unreachable
cleanup: ; preds = %if.end.50, %cond.end, %land.lhs.true, %bb0
ret void
}
@yy_c_buf_p = external unnamed_addr global i8*, align 4
@dfg_text = external global i8*, align 4
define void @dfg_lex() {
;CHECK-LABEL: dfg_lex
entry:
br label %while.bodythread-pre-split
while.bodythread-pre-split: ; preds = %while.end, %while.end, %entry
br i1 undef, label %if.then.14, label %if.end.15
if.then.14: ; preds = %while.end, %while.bodythread-pre-split
%v1 = load i32, i32* bitcast (i8** @dfg_text to i32*), align 4
%sub.ptr.sub = sub i32 undef, %v1
br label %if.end.15
if.end.15: ; preds = %if.then.14, %while.bodythread-pre-split
%v2 = load i8*, i8** @yy_c_buf_p, align 4
br label %while.cond.16
while.cond.16: ; preds = %while.cond.16, %if.end.15
br i1 undef, label %while.cond.16, label %while.end
while.end: ; preds = %while.cond.16
%add.ptr = getelementptr inbounds i8, i8* %v2, i32 undef
store i8* %add.ptr, i8** @dfg_text, align 4
%sub.ptr.rhs.cast25 = ptrtoint i8* %add.ptr to i32
%sub.ptr.sub26 = sub i32 0, %sub.ptr.rhs.cast25
switch i32 undef, label %sw.default [
i32 65, label %while.bodythread-pre-split
i32 3, label %return
i32 57, label %while.bodythread-pre-split
i32 60, label %if.then.14
]
sw.default: ; preds = %while.end
unreachable
return: ; preds = %while.end
ret void
}