[llvm] r269433 - [MemCpyOpt] Use MaxIntSize in byte instead of bit
Jun Bum Lim via llvm-commits
llvm-commits at lists.llvm.org
Fri May 13 09:52:24 PDT 2016
Author: junbuml
Date: Fri May 13 11:52:24 2016
New Revision: 269433
URL: http://llvm.org/viewvc/llvm-project?rev=269433&view=rev
Log:
[MemCpyOpt] Use MaxIntSize in byte instead of bit
Summary: This change fix the bug in isProfitableToUseMemset() where MaxIntSize shoule be in byte, not bit.
Reviewers: arsenm, joker.eph, mcrosier
Subscribers: mcrosier, llvm-commits
Differential Revision: http://reviews.llvm.org/D20176
Added:
llvm/trunk/test/Transforms/MemCpyOpt/profitable-memset.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=269433&r1=269432&r2=269433&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Fri May 13 11:52:24 2016
@@ -185,7 +185,7 @@ bool MemsetRange::isProfitableToUseMemse
// size. If so, check to see whether we will end up actually reducing the
// number of stores used.
unsigned Bytes = unsigned(End-Start);
- unsigned MaxIntSize = DL.getLargestLegalIntTypeSize();
+ unsigned MaxIntSize = DL.getLargestLegalIntTypeSize() / 8;
if (MaxIntSize == 0)
MaxIntSize = 1;
unsigned NumPointerStores = Bytes / MaxIntSize;
Added: llvm/trunk/test/Transforms/MemCpyOpt/profitable-memset.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/profitable-memset.ll?rev=269433&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/MemCpyOpt/profitable-memset.ll (added)
+++ llvm/trunk/test/Transforms/MemCpyOpt/profitable-memset.ll Fri May 13 11:52:24 2016
@@ -0,0 +1,20 @@
+; RUN: opt < %s -memcpyopt -S | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
+
+; CHECK-LABEL: @foo(
+; CHECK-NOT: store
+; CHECK: call void @llvm.memset.p0i8.i64(i8* %2, i8 0, i64 8, i32 2, i1 false)
+
+define void @foo(i64* nocapture %P) {
+entry:
+ %0 = bitcast i64* %P to i16*
+ %arrayidx = getelementptr inbounds i16, i16* %0, i64 1
+ %1 = bitcast i16* %arrayidx to i32*
+ %arrayidx1 = getelementptr inbounds i16, i16* %0, i64 3
+ store i16 0, i16* %0, align 2
+ store i32 0, i32* %1, align 4
+ store i16 0, i16* %arrayidx1, align 2
+ ret void
+}
+
More information about the llvm-commits
mailing list