[LLVMbugs] [Bug 5284] New: llvm.bswap.i{16, 32} is not constant folded
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Fri Oct 23 02:24:43 PDT 2009
http://llvm.org/bugs/show_bug.cgi?id=5284
Summary: llvm.bswap.i{16,32} is not constant folded
Product: new-bugs
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: edwintorok at gmail.com
CC: llvmbugs at cs.uiuc.edu
In the testcase the llvm.bswap.i{16,32} calls should be constant-folded:
%call.i.i = tail call zeroext i1 @is_bigendian() nounwind readnone ; <i1>
[#uses=2]
%call1.i = select i1 %call.i.i, i32 83886080, i32 5 ; <i32> [#uses=5]
..
br i1 %call.i.i, label %cond.true.i.i, label %cli_readint16.exit.thread
cond.true.i.i: ; preds = %entry
%trunc = trunc i32 %call1.i to i16 ; <i16> [#uses=1]
%or.i.i = tail call i16 @llvm.bswap.i16(i16 %trunc) nounwind ; <i16>
[#uses=1]
%conv = zext i16 %or.i.i to i32 ; <i32> [#uses=1]
%tmp1.i.i = tail call i32 @llvm.bswap.i32(i32 %call1.i) nounwind ; <i32>
[#uses=1]
br label %cli_readint32.exit
^
Instcombine should realise that on cond.true.i.i the value of cal1.i is i32
83886080, and constant propagate that.
Also in the attached testcase the bswaps can be completely eliminated, since
br i1 %call.i.i, label %cond.true.i.i10, label %cli_writeint32.exit.thread
%cond.true.i.i10 unconditionally ranches to cli_readint16.exit, which has:
%a.val2 = phi i32 [ %tmp1.i.i, %cond.true.i.i10 ], [ %v,
%cli_writeint32.exit.thread ] ; <i32> [#uses=2]
....
br i1 %call.i.i, label %cond.true.i.i7, label %cli_readint32.exit
cond.true.i.i7: ; preds = %cli_readint16.exit
%tmp1.i.i6 = tail call i32 @llvm.bswap.i32(i32 %a.val2) nounwind ; <i32>
[#uses=1]
br label %cli_readint32.exit
Now cond.true.i.i7 is reached if %call.i.i is true, which means that a PHI
translation should tell us that %a.val2 is actuall %tmp1.i.i in that case, so
we could propagate:
%tmp1.i.i6 = tail call i32 @llvm.bswap.i32(i32 %tmp1.i.i) nounwind ; <i32>
[#uses=1]
And this is an identity transform bswap(bswap(%v)) == %v, so we should have:
%tmp1.i.i16 = %v
Similarly this PHI:
%call48 = phi i32 [ %tmp1.i.i6, %cond.true.i.i7 ], [ %a.val2,
%cli_readint16.exit ]
should be simplified to
%call48 = %v (Since %a.val2 is %v on the other branch)
--
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