2016-04-07 17:45:02 +02:00
|
|
|
; RUN: opt -gvn -S < %s | FileCheck %s
|
|
|
|
|
|
|
|
target datalayout = "E-m:e-i64:64-n32:64"
|
|
|
|
target triple = "powerpc64-unknown-linux-gnu"
|
|
|
|
|
|
|
|
;; Make sure we use correct bit shift based on storage size for
|
|
|
|
;; loads reusing a load value.
|
|
|
|
define i64 @test1({ i1, i8 }* %predA, { i1, i8 }* %predB) {
|
|
|
|
; CHECK-LABEL: @test1
|
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 20:42:35 +02:00
|
|
|
; CHECK-NOT: [[V1:%.*]] = load i16, i16* %{{.*}}
|
|
|
|
; CHECK-NOT: [[V2:%.*]] = lshr i16 [[V1]], 8
|
|
|
|
; CHECK-NOT: trunc i16 [[V2]] to i1
|
2016-04-07 17:45:02 +02:00
|
|
|
|
|
|
|
%valueLoadA.fca.0.gep = getelementptr inbounds { i1, i8 }, { i1, i8 }* %predA, i64 0, i32 0
|
|
|
|
%valueLoadA.fca.0.load = load i1, i1* %valueLoadA.fca.0.gep, align 8
|
|
|
|
%valueLoadB.fca.0.gep = getelementptr inbounds { i1, i8 }, { i1, i8 }* %predB, i64 0, i32 0
|
|
|
|
%valueLoadB.fca.0.load = load i1, i1* %valueLoadB.fca.0.gep, align 8
|
|
|
|
%isTrue = and i1 %valueLoadA.fca.0.load, %valueLoadB.fca.0.load
|
|
|
|
%valueLoadA.fca.1.gep = getelementptr inbounds { i1, i8 }, { i1, i8 }* %predA, i64 0, i32 1
|
|
|
|
%valueLoadA.fca.1.load = load i8, i8* %valueLoadA.fca.1.gep, align 1
|
|
|
|
%isNotNullA = icmp ne i8 %valueLoadA.fca.1.load, 0
|
|
|
|
%valueLoadB.fca.1.gep = getelementptr inbounds { i1, i8 }, { i1, i8 }* %predB, i64 0, i32 1
|
|
|
|
%valueLoadB.fca.1.load = load i8, i8* %valueLoadB.fca.1.gep, align 1
|
|
|
|
%isNotNullB = icmp ne i8 %valueLoadB.fca.1.load, 0
|
|
|
|
%isNotNull = and i1 %isNotNullA, %isNotNullB
|
|
|
|
%isTrueAndNotNull = and i1 %isTrue, %isNotNull
|
|
|
|
%ret = zext i1 %isTrueAndNotNull to i64
|
|
|
|
ret i64 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
;; And likewise for loads reusing a store value.
|
|
|
|
define i1 @test2(i8 %V, i8* %P) {
|
|
|
|
; CHECK-LABEL: @test2
|
|
|
|
; CHECK-NOT: lshr
|
|
|
|
store i8 %V, i8* %P
|
|
|
|
%P2 = bitcast i8* %P to i1*
|
|
|
|
%A = load i1, i1* %P2
|
|
|
|
ret i1 %A
|
|
|
|
}
|
|
|
|
|