1; RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-linux-gnu < %s \
2; RUN:   -verify-machineinstrs | FileCheck %s
3
4@b = dso_local local_unnamed_addr global i64* null, align 8
5@a = dso_local local_unnamed_addr global i8 0, align 1
6
7define void @testADDEPromoteResult() {
8entry:
9  %0 = load i64*, i64** @b, align 8
10  %1 = load i64, i64* %0, align 8
11  %cmp = icmp ne i64* %0, null
12  %conv1 = zext i1 %cmp to i64
13  %add = add nsw i64 %1, %conv1
14  %2 = trunc i64 %add to i8
15  %conv2 = and i8 %2, 5
16  store i8 %conv2, i8* @a, align 1
17  ret void
18
19; CHECK-LABEL: @testADDEPromoteResult
20; CHECK:      # %bb.0:
21; CHECK-DAG:   addis [[REG1:[0-9]+]], [[REG2:[0-9]+]], [[VAR1:[a-z0-9A-Z_.]+]]@toc@ha
22; CHECK-DAG:   ld [[REG3:[0-9]+]], [[VAR1]]@toc@l([[REG1]])
23; CHECK-DAG:   lbz [[REG4:[0-9]+]], 0([[REG3]])
24; CHECK-DAG:   addi [[REG7:[0-9]+]], [[REG4]]
25; CHECK-DAG:   andi. [[REG9:[0-9]+]], [[REG7]], 5
26; CHECK-DAG:   addis [[REG8:[0-9]+]], [[REG2]], [[VAR2:[a-z0-9A-Z_.]+]]@toc@ha
27; CHECK-DAG:   stb [[REG9]], [[VAR2]]@toc@l([[REG8]])
28; CHECK:       blr
29}
30