1 ; RUN: opt -gvn -S < %s | FileCheck %s
3 target datalayout = "E-m:e-i64:64-n32:64"
4 target triple = "powerpc64-unknown-linux-gnu"
6 ;; Make sure we use correct bit shift based on storage size for
7 ;; loads reusing a load value.
8 define i64 @test1({ i1, i8 }* %predA, { i1, i8 }* %predB) {
10 ; CHECK-NOT: [[V1:%.*]] = load i16, i16* %{{.*}}
11 ; CHECK-NOT: [[V2:%.*]] = lshr i16 [[V1]], 8
12 ; CHECK-NOT: trunc i16 [[V2]] to i1
14 %valueLoadA.fca.0.gep = getelementptr inbounds { i1, i8 }, { i1, i8 }* %predA, i64 0, i32 0
15 %valueLoadA.fca.0.load = load i1, i1* %valueLoadA.fca.0.gep, align 8
16 %valueLoadB.fca.0.gep = getelementptr inbounds { i1, i8 }, { i1, i8 }* %predB, i64 0, i32 0
17 %valueLoadB.fca.0.load = load i1, i1* %valueLoadB.fca.0.gep, align 8
18 %isTrue = and i1 %valueLoadA.fca.0.load, %valueLoadB.fca.0.load
19 %valueLoadA.fca.1.gep = getelementptr inbounds { i1, i8 }, { i1, i8 }* %predA, i64 0, i32 1
20 %valueLoadA.fca.1.load = load i8, i8* %valueLoadA.fca.1.gep, align 1
21 %isNotNullA = icmp ne i8 %valueLoadA.fca.1.load, 0
22 %valueLoadB.fca.1.gep = getelementptr inbounds { i1, i8 }, { i1, i8 }* %predB, i64 0, i32 1
23 %valueLoadB.fca.1.load = load i8, i8* %valueLoadB.fca.1.gep, align 1
24 %isNotNullB = icmp ne i8 %valueLoadB.fca.1.load, 0
25 %isNotNull = and i1 %isNotNullA, %isNotNullB
26 %isTrueAndNotNull = and i1 %isTrue, %isNotNull
27 %ret = zext i1 %isTrueAndNotNull to i64
31 ;; And likewise for loads reusing a store value.
32 define i1 @test2(i8 %V, i8* %P) {
36 %P2 = bitcast i8* %P to i1*