xref: /llvm-project/llvm/test/CodeGen/PowerPC/fold-remove-li.ll (revision 427fb35192f1f7bb694a5910b05abc5925a798b2)
1; NOTE: This test verifies that a redundant load immediate of zero is folded
2; NOTE: from its use in an isel and deleted as it is no longer in use.
3; RUN:  llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-linux-gnu \
4; RUN:      -ppc-asm-full-reg-names -verify-machineinstrs < %s | FileCheck %s
5; RUN:  llc -mcpu=pwr9 -mtriple=powerpc64-unknown-linux-gnu \
6; RUN:      -ppc-asm-full-reg-names -verify-machineinstrs < %s | FileCheck %s
7
8%0 = type { i32, i16 }
9
10@val = common dso_local local_unnamed_addr global ptr null, align 8
11
12define dso_local signext i32 @redunLoadImm(ptr %arg) {
13; CHECK-LABEL: redunLoadImm:
14; verify that the load immediate has been folded into the isel and deleted
15; CHECK-NOT:   li r[[REG1:[0-9]+]], 0
16; CHECK:       iseleq r[[REG2:[0-9]+]], 0, r[[REG3:[0-9]+]]
17
18bb:
19  %tmp = icmp eq ptr %arg, null
20  br i1 %tmp, label %bb9, label %bb1
21
22bb1:                                              ; preds = %bb
23  %tmp2 = getelementptr inbounds %0, ptr %arg, i64 0, i32 1
24  br label %bb3
25
26bb3:                                              ; preds = %bb3, %bb1
27  %tmp4 = load i16, ptr %tmp2, align 4
28  %tmp5 = sext i16 %tmp4 to i64
29  %tmp6 = getelementptr inbounds %0, ptr %arg, i64 %tmp5
30  %tmp7 = icmp eq i16 %tmp4, 0
31  %tmp8 = select i1 %tmp7, ptr null, ptr %tmp6
32  store ptr %tmp8, ptr @val, align 8
33  br label %bb3
34
35bb9:                                              ; preds = %bb
36  %tmp10 = load ptr, ptr @val, align 8
37  %tmp12 = load i32, ptr %tmp10, align 4
38  ret i32 %tmp12
39}
40