[llvm-commits] [llvm] r156231 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCasts.cpp test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll
Stepan Dyatkovskiy
stpworld at narod.ru
Sat May 5 00:09:40 PDT 2012
Author: dyatkovskiy
Date: Sat May 5 02:09:40 2012
New Revision: 156231
URL: http://llvm.org/viewvc/llvm-project?rev=156231&view=rev
Log:
Small fix in InstCombineCasts.cpp. Restored "alloca + bitcast" reducing for case when alloca's size is calculated within the "add/sub/... nsw".
Also added fix to 2011-06-13-nsw-alloca.ll test.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/trunk/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=156231&r1=156230&r2=156231&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Sat May 5 02:09:40 2012
@@ -34,7 +34,7 @@
if (BinaryOperator *I = dyn_cast<BinaryOperator>(Val)) {
// Cannot look past anything that might overflow.
OverflowingBinaryOperator *OBI = dyn_cast<OverflowingBinaryOperator>(Val);
- if (OBI && !OBI->hasNoUnsignedWrap()) {
+ if (OBI && !OBI->hasNoUnsignedWrap() && !OBI->hasNoSignedWrap()) {
Scale = 1;
Offset = 0;
return Val;
Modified: llvm/trunk/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll?rev=156231&r1=156230&r2=156231&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll Sat May 5 02:09:40 2012
@@ -2,8 +2,10 @@
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-n8:16:32"
target triple = "i386-apple-darwin10.0.0"
+; CHECK: define void @fu1
define void @fu1(i32 %parm) nounwind ssp {
%1 = alloca i32, align 4
+; CHECK: alloca double*
%ptr = alloca double*, align 4
store i32 %parm, i32* %1, align 4
store double* null, double** %ptr, align 4
@@ -16,12 +18,12 @@
%6 = mul nsw i32 %5, 8
; With "nsw", the alloca and its bitcast can be fused:
%7 = add nsw i32 %6, 2048
-; CHECK: alloca double*
+; CHECK: alloca double
%8 = alloca i8, i32 %7
%9 = bitcast i8* %8 to double*
+; CHECK-NEXT: store double*
store double* %9, double** %ptr, align 4
br label %10
-
; <label>:10 ; preds = %4, %0
%11 = load double** %ptr, align 4
call void @bar(double* %11)
@@ -31,6 +33,7 @@
declare void @bar(double*)
+; CHECK: define void @fu2
define void @fu2(i32 %parm) nounwind ssp {
%1 = alloca i32, align 4
%ptr = alloca double*, align 4
More information about the llvm-commits
mailing list