| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| ; RUN: opt -instcombine -S < %s | FileCheck %s |
| |
| |
| declare i8* @memcpy(i8* nocapture, i8* nocapture, i64) |
| declare i8* @strncpy(i8* nocapture, i8* nocapture, i64) |
| declare i8* @strcpy(i8* nocapture, i8* nocapture) |
| |
| define i8* @memcpy_const_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s) { |
| ; CHECK-LABEL: @memcpy_const_size_noalias( |
| ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias align 1 dereferenceable(16) [[D:%.*]], i8* noalias align 1 dereferenceable(16) [[S:%.*]], i64 16, i1 false) |
| ; CHECK-NEXT: ret i8* [[D]] |
| ; |
| %call = tail call i8* @memcpy(i8* %d, i8* %s, i64 16) |
| ret i8* %call |
| } |
| |
| define i8* @memcpy_const_zero_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s) { |
| ; CHECK-LABEL: @memcpy_const_zero_size_noalias( |
| ; CHECK-NEXT: ret i8* [[D:%.*]] |
| ; |
| %call = tail call i8* @memcpy(i8* %d, i8* %s, i64 0) |
| ret i8* %call |
| } |
| |
| define i8* @memcpy_nonconst_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s, i64 %n) { |
| ; CHECK-LABEL: @memcpy_nonconst_size_noalias( |
| ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias align 1 [[D:%.*]], i8* noalias align 1 [[S:%.*]], i64 [[N:%.*]], i1 false) |
| ; CHECK-NEXT: ret i8* [[D]] |
| ; |
| %call = tail call i8* @memcpy(i8* %d, i8* %s, i64 %n) |
| ret i8* %call |
| } |
| |
| define i8* @strncpy_const_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s) { |
| ; CHECK-LABEL: @strncpy_const_size_noalias( |
| ; CHECK-NEXT: [[CALL:%.*]] = tail call i8* @strncpy(i8* noalias [[D:%.*]], i8* noalias [[S:%.*]], i64 16) |
| ; CHECK-NEXT: ret i8* [[CALL]] |
| ; |
| %call = tail call i8* @strncpy(i8* %d, i8* %s, i64 16) |
| ret i8* %call |
| } |
| |
| define i8* @strncpy_const_zero_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s) { |
| ; CHECK-LABEL: @strncpy_const_zero_size_noalias( |
| ; CHECK-NEXT: [[CALL:%.*]] = tail call i8* @strncpy(i8* noalias [[D:%.*]], i8* noalias [[S:%.*]], i64 0) |
| ; CHECK-NEXT: ret i8* [[CALL]] |
| ; |
| %call = tail call i8* @strncpy(i8* %d, i8* %s, i64 0) |
| ret i8* %call |
| } |
| |
| define i8* @strncpy_nonconst_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s, i64 %n) { |
| ; CHECK-LABEL: @strncpy_nonconst_size_noalias( |
| ; CHECK-NEXT: [[CALL:%.*]] = tail call i8* @strncpy(i8* noalias [[D:%.*]], i8* noalias [[S:%.*]], i64 [[N:%.*]]) |
| ; CHECK-NEXT: ret i8* [[CALL]] |
| ; |
| %call = tail call i8* @strncpy(i8* %d, i8* %s, i64 %n) |
| ret i8* %call |
| } |
| |
| define i8* @strcpy_const_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s) { |
| ; CHECK-LABEL: @strcpy_const_size_noalias( |
| ; CHECK-NEXT: [[CALL:%.*]] = tail call i8* @strcpy(i8* noalias [[D:%.*]], i8* noalias [[S:%.*]]) |
| ; CHECK-NEXT: ret i8* [[CALL]] |
| ; |
| %call = tail call i8* @strcpy(i8* %d, i8* %s) |
| ret i8* %call |
| } |
| |
| define i8* @strcpy_nonconst_size_noalias(i8* nocapture readonly %d, i8* nocapture readonly %s) { |
| ; CHECK-LABEL: @strcpy_nonconst_size_noalias( |
| ; CHECK-NEXT: [[CALL:%.*]] = tail call i8* @strcpy(i8* noalias [[D:%.*]], i8* noalias [[S:%.*]]) |
| ; CHECK-NEXT: ret i8* [[CALL]] |
| ; |
| %call = tail call i8* @strcpy(i8* %d, i8* %s) |
| ret i8* %call |
| } |