[LLVMbugs] [Bug 2261] New: SCEV creates unneeded SMAX node
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Tue Apr 29 06:22:26 PDT 2008
http://llvm.org/bugs/show_bug.cgi?id=2261
Summary: SCEV creates unneeded SMAX node
Product: libraries
Version: 1.0
Platform: PC
OS/Version: All
Status: NEW
Keywords: code-quality
Severity: normal
Priority: P2
Component: Global Analyses
AssignedTo: unassignedbugs at nondot.org
ReportedBy: sabre at nondot.org
CC: llvmbugs at cs.uiuc.edu
This (unremarkable) testcase from the GCC testsuite
gcc/testsuite/gcc.apple/i386-bitmask1.c compiles into:
entry:
%tmp2126 = icmp sgt i32 %count, 0 ; <i1> [#uses=1]
br i1 %tmp2126, label %bb.preheader, label %return
bb.preheader: ; preds = %entry
%tmp = icmp slt i32 %count, 1 ; <i1> [#uses=1]
%smax = select i1 %tmp, i32 1, i32 %count ; <i32>
[#uses=1]
br label %bb
..
This is because a SCEV is created with an SMAX(count,1) node, even though the
whole loop is dominated by a check that count is > 0. SCEV should do a little
bit of analysis of dominating branches to simplify the SCEV expressions in this
extremely common case. While we could make follow-on optimizations catch this,
it is better to just not insert it in the first place, and having more precise
SCEV expressions is always good.
The full test is:
unsigned char lut[256];
void foo( int count, unsigned int *srcptr, unsigned *dstptr ) {
int j;
for (j = 0; j < count; j++) {
unsigned int tmp = *srcptr;
unsigned int alpha = (tmp&255);
tmp &= 0xffffff00;
alpha =lut[alpha];
tmp |= alpha<<0;
*dstptr = 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