1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00
llvm-mirror/test/Transforms/InstCombine/memrchr.ll
Nikita Popov cf8ee33937 [IR] Convert null-pointer-is-valid into an enum attribute
The "null-pointer-is-valid" attribute needs to be checked by many
pointer-related combines. To make the check more efficient, convert
it from a string into an enum attribute.

In the future, this attribute may be replaced with data layout
properties.

Differential Revision: https://reviews.llvm.org/D78862
2020-05-15 19:41:07 +02:00

56 lines
1.5 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
declare i8* @memrchr(i8*, i32, i32)
define i8* @test1(i8* %str, i32 %c, i32 %n) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* [[STR:%.*]], i32 [[C:%.*]], i32 [[N:%.*]])
; CHECK-NEXT: ret i8* [[RET]]
;
%ret = call i8* @memrchr(i8* %str, i32 %c, i32 %n)
ret i8* %ret
}
define i8* @test2(i8* %str, i32 %c, i32 %n) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* nonnull [[STR:%.*]], i32 [[C:%.*]], i32 [[N:%.*]])
; CHECK-NEXT: ret i8* [[RET]]
;
%ret = call i8* @memrchr(i8* nonnull %str, i32 %c, i32 %n)
ret i8* %ret
}
define i8* @test3(i8* %str, i32 %c) {
; CHECK-LABEL: @test3(
; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* [[STR:%.*]], i32 [[C:%.*]], i32 5)
; CHECK-NEXT: ret i8* [[RET]]
;
%ret = call i8* @memrchr(i8* %str, i32 %c, i32 5)
ret i8* %ret
}
define i8* @test4(i8* %str, i32 %c) null_pointer_is_valid {
; CHECK-LABEL: @test4(
; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* [[STR:%.*]], i32 [[C:%.*]], i32 5)
; CHECK-NEXT: ret i8* [[RET]]
;
%ret = call i8* @memrchr(i8* %str, i32 %c, i32 5)
ret i8* %ret
}
define i8* @test5(i8* %str, i32 %c) {
; CHECK-LABEL: @test5(
; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* [[STR:%.*]], i32 [[C:%.*]], i32 0)
; CHECK-NEXT: ret i8* [[RET]]
;
%ret = call i8* @memrchr(i8* %str, i32 %c, i32 0)
ret i8* %ret
}