1; RUN: opt -gvn -S < %s | FileCheck %s 2 3target datalayout = "E-m:e-i64:64-n32:64" 4target triple = "powerpc64-unknown-linux-gnu" 5 6;; Make sure we use correct bit shift based on storage size for 7;; loads reusing a load value. 8define i64 @test1({ i1, i8 }* %predA, { i1, i8 }* %predB) { 9; CHECK-LABEL: @test1 10; CHECK: [[V1:%.*]] = load i16, i16* %{{.*}} 11; CHECK: [[V2:%.*]] = lshr i16 [[V1]], 8 12; CHECK: trunc i16 [[V2]] to i1 13 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 28 ret i64 %ret 29} 30 31;; And likewise for loads reusing a store value. 32define i1 @test2(i8 %V, i8* %P) { 33; CHECK-LABEL: @test2 34; CHECK-NOT: lshr 35 store i8 %V, i8* %P 36 %P2 = bitcast i8* %P to i1* 37 %A = load i1, i1* %P2 38 ret i1 %A 39} 40 41