[LLVMbugs] [Bug 9588] New: Repeated generation of 0 constant
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Mar 29 21:53:42 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=9588
Summary: Repeated generation of 0 constant
Product: libraries
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
AssignedTo: unassignedbugs at nondot.org
ReportedBy: jmuizelaar at mozilla.com
CC: llvmbugs at cs.uiuc.edu
The following code:
#include <stdint.h>
#include <stdbool.h>
struct colorant {
int32_t X;
int32_t Y;
int32_t Z;
};
struct qcms_profile
{
struct colorant redColorant;
struct colorant blueColorant;
struct colorant greenColorant;
};
static inline float s15Fixed16Number_to_float(int32_t a)
{
return ((int32_t)a)/65536.f;
}
bool qcms_profile_is_bogus(struct qcms_profile *profile)
{
float sum[3], target[3], tolerance[3];
float rX, rY, rZ, gX, gY, gZ, bX, bY, bZ;
bool negative;
unsigned i;
rX = s15Fixed16Number_to_float(profile->redColorant.X);
rY = s15Fixed16Number_to_float(profile->redColorant.Y);
rZ = s15Fixed16Number_to_float(profile->redColorant.Z);
gX = s15Fixed16Number_to_float(profile->greenColorant.X);
gY = s15Fixed16Number_to_float(profile->greenColorant.Y);
gZ = s15Fixed16Number_to_float(profile->greenColorant.Z);
bX = s15Fixed16Number_to_float(profile->blueColorant.X);
bY = s15Fixed16Number_to_float(profile->blueColorant.Y);
bZ = s15Fixed16Number_to_float(profile->blueColorant.Z);
// Check if any of the XYZ values are negative (see mozilla bug 498245)
// CIEXYZ tristimulus values cannot be negative according to the spec.
negative =
(rX < 0) || (rY < 0) || (rZ < 0) ||
(gX < 0) || (gY < 0) || (gZ < 0) ||
(bX < 0) || (bY < 0) || (bZ < 0);
if (negative)
return true;
// All Good
return false;
}
code compiles (clang -Os -S test.c -o test-clang.s) to:
qcms_profile_is_bogus: # @qcms_profile_is_bogus
movss .LCPI0_0(%rip), %xmm0
cvtsi2ss (%rdi), %xmm1
divss %xmm0, %xmm1
pxor %xmm2, %xmm2
ucomiss %xmm1, %xmm2
movb $1, %al
ja .LBB0_9
cvtsi2ss 4(%rdi), %xmm1
divss %xmm0, %xmm1
ucomiss %xmm1, %xmm2
ja .LBB0_9
cvtsi2ss 8(%rdi), %xmm1
divss %xmm0, %xmm1
pxor %xmm2, %xmm2
ucomiss %xmm1, %xmm2
ja .LBB0_9
cvtsi2ss 24(%rdi), %xmm1
divss %xmm0, %xmm1
ucomiss %xmm1, %xmm2
ja .LBB0_9
cvtsi2ss 28(%rdi), %xmm1
divss %xmm0, %xmm1
pxor %xmm2, %xmm2
ucomiss %xmm1, %xmm2
ja .LBB0_9
cvtsi2ss 32(%rdi), %xmm1
divss %xmm0, %xmm1
ucomiss %xmm1, %xmm2
ja .LBB0_9
cvtsi2ss 12(%rdi), %xmm1
divss %xmm0, %xmm1
pxor %xmm2, %xmm2
ucomiss %xmm1, %xmm2
ja .LBB0_9
cvtsi2ss 16(%rdi), %xmm1
divss %xmm0, %xmm1
ucomiss %xmm1, %xmm2
ja .LBB0_9
cvtsi2ss 20(%rdi), %xmm0
divss .LCPI0_0(%rip), %xmm0
pxor %xmm1, %xmm1
ucomiss %xmm0, %xmm1
seta %al
.LBB0_9: # %lor.end
movzbl %al, %eax
ret
This repeatedly pxor's a register to get a 0. It seems like we should be able
to preserve the 0 for the duration of the function.
--
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