[LLVMbugs] [Bug 5645] New: llvm fails to fold function to a constant when built with clang
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Mon Nov 30 11:35:29 PST 2009
http://llvm.org/bugs/show_bug.cgi?id=5645
Summary: llvm fails to fold function to a constant when built
with clang
Product: libraries
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Scalar Optimizations
AssignedTo: unassignedbugs at nondot.org
ReportedBy: daniel at zuster.org
CC: llvmbugs at cs.uiuc.edu
The f6() function in the attached .cpp file fails to fold to a constant when
compiled with clang. This is bad, and I'm optimistically assuming its the
backends fault. LLVM does manage to fold it down if it happens to inline it, so
I suspect its something to do with aliasing on the alloca.
--
ddunbar at ozzy:tmp$ llvm-gcc -flto -S -O3 -o - t.cpp
; ModuleID = 't.cpp'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-apple-darwin10.0"
define i32 @_Z2f6v() nounwind ssp {
bb.i43:
ret i32 1251552576
}
ddunbar at ozzy:tmp$ clang -flto -S -O3 -o - t.cpp
; ModuleID = 't.cpp'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-apple-darwin10.0"
%struct.TempTracker = type { i32, i32 }
define i32 @_Z2f6v() nounwind ssp {
while.body.i.i98.preheader:
%tt = alloca %struct.TempTracker, align 4 ; <%struct.TempTracker*>
[#uses=2]
%tmp.i = getelementptr inbounds %struct.TempTracker* %tt, i64 0, i32 0 ;
<i32*> [#uses=5]
%tmp9.i152 = getelementptr inbounds %struct.TempTracker* %tt, i64 0, i32 1 ;
<i32*> [#uses=5]
store i32 3, i32* %tmp.i
store i32 2, i32* %tmp9.i152
br label %while.body.i.i98
while.body.i.i98: ; preds =
%while.body.i.i98.preheader, %while.body.i.i98
%indvar.i.i93 = phi i32 [ %indvar.next.i.i96, %while.body.i.i98 ], [ 0,
%while.body.i.i98.preheader ] ; <i32> [#uses=1]
%Val.06.i.i94 = phi i32 [ %mul.i.i95, %while.body.i.i98 ], [ 1,
%while.body.i.i98.preheader ] ; <i32> [#uses=2]
%mul.i.i95 = mul i32 %Val.06.i.i94, 7 ; <i32> [#uses=1]
%indvar.next.i.i96 = add i32 %indvar.i.i93, 1 ; <i32> [#uses=2]
%exitcond = icmp eq i32 %indvar.next.i.i96, 2 ; <i1> [#uses=1]
br i1 %exitcond, label %while.body.i.i74.preheader, label %while.body.i.i98
while.body.i.i74.preheader: ; preds = %while.body.i.i98
%phitmp = mul i32 %Val.06.i.i94, 21 ; <i32> [#uses=2]
store i32 %phitmp, i32* %tmp.i
store i32 3, i32* %tmp9.i152
br label %while.body.i.i74
while.body.i.i74: ; preds =
%while.body.i.i74.preheader, %while.body.i.i74
%indvar.i.i69 = phi i32 [ %indvar.next.i.i72, %while.body.i.i74 ], [ 0,
%while.body.i.i74.preheader ] ; <i32> [#uses=1]
%Val.06.i.i70 = phi i32 [ %mul.i.i71, %while.body.i.i74 ], [ 1,
%while.body.i.i74.preheader ] ; <i32> [#uses=1]
%mul.i.i71 = mul i32 %Val.06.i.i70, 11 ; <i32> [#uses=2]
%indvar.next.i.i72 = add i32 %indvar.i.i69, 1 ; <i32> [#uses=2]
%exitcond408 = icmp eq i32 %indvar.next.i.i72, 3 ; <i1> [#uses=1]
br i1 %exitcond408, label %while.body.i.i50.preheader, label
%while.body.i.i74
while.body.i.i50.preheader: ; preds = %while.body.i.i74
%mul.i79 = mul i32 %phitmp, %mul.i.i71 ; <i32> [#uses=2]
store i32 %mul.i79, i32* %tmp.i
store i32 4, i32* %tmp9.i152
br label %while.body.i.i50
while.body.i.i50: ; preds =
%while.body.i.i50.preheader, %while.body.i.i50
%indvar.i.i45 = phi i32 [ %indvar.next.i.i48, %while.body.i.i50 ], [ 0,
%while.body.i.i50.preheader ] ; <i32> [#uses=1]
%Val.06.i.i46 = phi i32 [ %mul.i.i47, %while.body.i.i50 ], [ 1,
%while.body.i.i50.preheader ] ; <i32> [#uses=1]
%mul.i.i47 = mul i32 %Val.06.i.i46, 5 ; <i32> [#uses=2]
%indvar.next.i.i48 = add i32 %indvar.i.i45, 1 ; <i32> [#uses=2]
%exitcond410 = icmp eq i32 %indvar.next.i.i48, 4 ; <i1> [#uses=1]
br i1 %exitcond410, label %while.body.i.i24.preheader, label
%while.body.i.i50
while.body.i.i24.preheader: ; preds = %while.body.i.i50
%mul.i55 = mul i32 %mul.i79, %mul.i.i47 ; <i32> [#uses=2]
store i32 %mul.i55, i32* %tmp.i
store i32 5, i32* %tmp9.i152
br label %while.body.i.i24
while.body.i.i24: ; preds =
%while.body.i.i24.preheader, %while.body.i.i24
%indvar.i.i19 = phi i32 [ %indvar.next.i.i22, %while.body.i.i24 ], [ 0,
%while.body.i.i24.preheader ] ; <i32> [#uses=1]
%Val.06.i.i20 = phi i32 [ %mul.i.i21, %while.body.i.i24 ], [ 1,
%while.body.i.i24.preheader ] ; <i32> [#uses=1]
%mul.i.i21 = mul i32 %Val.06.i.i20, 13 ; <i32> [#uses=2]
%indvar.next.i.i22 = add i32 %indvar.i.i19, 1 ; <i32> [#uses=2]
%exitcond412 = icmp eq i32 %indvar.next.i.i22, 5 ; <i1> [#uses=1]
br i1 %exitcond412, label %while.body.i.i.preheader, label %while.body.i.i24
while.body.i.i.preheader: ; preds = %while.body.i.i24
%mul.i29 = mul i32 %mul.i55, %mul.i.i21 ; <i32> [#uses=2]
store i32 %mul.i29, i32* %tmp.i
store i32 6, i32* %tmp9.i152
br label %while.body.i.i
while.body.i.i: ; preds =
%while.body.i.i.preheader, %while.body.i.i
%indvar.i.i = phi i32 [ %indvar.next.i.i, %while.body.i.i ], [ 0,
%while.body.i.i.preheader ] ; <i32> [#uses=1]
%Val.06.i.i = phi i32 [ %mul.i.i, %while.body.i.i ], [ 1,
%while.body.i.i.preheader ] ; <i32> [#uses=1]
%mul.i.i = shl i32 %Val.06.i.i, 1 ; <i32> [#uses=2]
%indvar.next.i.i = add i32 %indvar.i.i, 1 ; <i32> [#uses=2]
%exitcond414 = icmp eq i32 %indvar.next.i.i, 6 ; <i1> [#uses=1]
br i1 %exitcond414, label %_ZN1AD1Ev.exit, label %while.body.i.i
_ZN1AD1Ev.exit: ; preds = %while.body.i.i
%mul.i = mul i32 %mul.i29, %mul.i.i ; <i32> [#uses=1]
ret i32 %mul.i
}
ddunbar at ozzy:tmp$
--
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list