1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00
llvm-mirror/test/CodeGen/PowerPC/pr39815.ll
Danila Kutenin cc8987f5b5 [ValueTracking] Pointer is known nonnull after load/store
If the pointer was loaded/stored before the null check, the check
is redundant and can be removed. For now the optimizers do not
remove the nullptr check, see https://gcc.godbolt.org/z/H2r5GG.
The patch allows to use more nonnull constraints. Also, it found
one more optimization in some PowerPC test. This is my first llvm
review, I am free to any comments.

Differential Revision: https://reviews.llvm.org/D71177
2019-12-11 20:32:29 +01:00

30 lines
1.0 KiB
LLVM

; RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-linux-gnu < %s \
; RUN: -verify-machineinstrs | FileCheck %s
@b = dso_local local_unnamed_addr global i64* null, align 8
@a = dso_local local_unnamed_addr global i8 0, align 1
define void @testADDEPromoteResult() {
entry:
%0 = load i64*, i64** @b, align 8
%1 = load i64, i64* %0, align 8
%cmp = icmp ne i64* %0, null
%conv1 = zext i1 %cmp to i64
%add = add nsw i64 %1, %conv1
%2 = trunc i64 %add to i8
%conv2 = and i8 %2, 5
store i8 %conv2, i8* @a, align 1
ret void
; CHECK-LABEL: @testADDEPromoteResult
; CHECK: # %bb.0:
; CHECK-DAG: addis [[REG1:[0-9]+]], [[REG2:[0-9]+]], [[VAR1:[a-z0-9A-Z_.]+]]@toc@ha
; CHECK-DAG: ld [[REG3:[0-9]+]], [[VAR1]]@toc@l([[REG1]])
; CHECK-DAG: lbz [[REG4:[0-9]+]], 0([[REG3]])
; CHECK-DAG: addi [[REG7:[0-9]+]], [[REG4]]
; CHECK-DAG: andi. [[REG9:[0-9]+]], [[REG7]], 5
; CHECK-DAG: addis [[REG8:[0-9]+]], [[REG2]], [[VAR2:[a-z0-9A-Z_.]+]]@toc@ha
; CHECK-DAG: stb [[REG9]], [[VAR2]]@toc@l([[REG8]])
; CHECK: blr
}