diff options
| author | Mikael Holmen <mikael.holmen@ericsson.com> | 2017-03-01 06:45:20 +0000 | 
|---|---|---|
| committer | Mikael Holmen <mikael.holmen@ericsson.com> | 2017-03-01 06:45:20 +0000 | 
| commit | 760dc9aba76ad48d74e6015b88da43b8c8e27674 (patch) | |
| tree | 8e9dd6da1ba454124be7ae9222b5a179c2987e34 /llvm/test/Transforms/InstCombine | |
| parent | 7cbbb88f238527dc6633c4cec1e1f057555410a3 (diff) | |
| download | bcm5719-llvm-760dc9aba76ad48d74e6015b88da43b8c8e27674.tar.gz bcm5719-llvm-760dc9aba76ad48d74e6015b88da43b8c8e27674.zip  | |
Remove sometimes faulty rewrite of memcpy in instcombine.
Summary:
Solves PR 31990.
The bad rewrite could replace a memcpy of one word with
 store i4 -1
while it should actually be
 store i8 -1
Hopefully opt and llc has improved enough so the original optimization
done by the code isn't needed anymore.
One already existing testcase is affected. It originally tested that
the memcpy was replaced with
 load double
but since we now remove that rewrite it will be
 load i64
instead.
Patch suggestion by Eli Friedman.
Reviewers: eli.friedman, majnemer, efriedma
Reviewed By: efriedma
Subscribers: efriedma, llvm-commits
Differential Revision: https://reviews.llvm.org/D30254
llvm-svn: 296585
Diffstat (limited to 'llvm/test/Transforms/InstCombine')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/memcpy-to-load.ll | 6 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/pr31990_wrong_memcpy.ll | 26 | 
2 files changed, 31 insertions, 1 deletions
diff --git a/llvm/test/Transforms/InstCombine/memcpy-to-load.ll b/llvm/test/Transforms/InstCombine/memcpy-to-load.ll index bcc9e188b96..fe5f0ac657f 100644 --- a/llvm/test/Transforms/InstCombine/memcpy-to-load.ll +++ b/llvm/test/Transforms/InstCombine/memcpy-to-load.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | grep "load double" +; RUN: opt < %s -instcombine -S | FileCheck %s  target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"  target triple = "i686-apple-darwin8" @@ -10,4 +10,8 @@ entry:    ret void  } +; Make sure that the memcpy has been replace with a load/store of i64 +; CHECK: [[TMP:%[0-9]+]] = load i64 +; CHECK: store i64 [[TMP]] +  declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind diff --git a/llvm/test/Transforms/InstCombine/pr31990_wrong_memcpy.ll b/llvm/test/Transforms/InstCombine/pr31990_wrong_memcpy.ll new file mode 100644 index 00000000000..62ecd0311ff --- /dev/null +++ b/llvm/test/Transforms/InstCombine/pr31990_wrong_memcpy.ll @@ -0,0 +1,26 @@ +; RUN: opt -S -instcombine %s -o - | FileCheck %s + +; Regression test of PR31990. A memcpy of one byte, copying 0xff, was +; replaced with a single store of an i4 0xf. + +@g = constant i8 -1 + +define void @foo() { +entry: +  %0 = alloca i8 +  %1 = bitcast i8* %0 to i4* +  call void @bar(i4* %1) +  %2 = bitcast i4* %1 to i8* +  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %2, i8* @g, i32 1, i32 1, i1 false) +  call void @gaz(i8* %2) +  ret void +} + +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, +                                        i8* nocapture readonly, i32, i32, i1) +declare void @bar(i4*) +declare void @gaz(i8*) + +; The mempcy should be simplified to a single store of an i8, not i4 +; CHECK: store i8 -1 +; CHECK-NOT: store i4 -1  | 

