[LLVMbugs] [Bug 7225] New: [ARM JIT] Color converter triggers ARM JIT to produce wrong shift operation
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue May 25 04:39:49 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=7225
Summary: [ARM JIT] Color converter triggers ARM JIT to produce
wrong shift operation
Product: libraries
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: Backend: ARM
AssignedTo: unassignedbugs at nondot.org
ReportedBy: sliao at google.com
CC: llvmbugs at cs.uiuc.edu
In our ARGB to ABGR (sorted) color converter,
void ARGB2ABGR(int *dst, int newpix, int x, int y)
{
newpix = (newpix & 0xff00ff00) | ((newpix & 0xff) << 16) | ((newpix >> 16) &
0xff);
...
}
ARM JIT will produce wrong code. newpix values become incorrect.
After narrowing down this further, I got similar but smaller code by making
some code dead.
void ARGB2ABGR_small(int *dst, int newpix, int x, int y)
{
unsigned int color = (unsigned int)newpix;
unsigned int ag = color & 0xff00ff00;
unsigned int b = (color & 0xff) << 16; // DEAD CODE. IGNORE!!
unsigned int r = (color & 0x00ff0000) >> 16;
dst[y*256+x] = ag | r;
}
The corresponding JITted code is wrong:
JIT: Disassembled code: init
0xf7d0b000: add r2, r2, r3, lsl #8
0xf7d0b004: movw r12, #65280
0xf7d0b008: movt r12, #65280
0xf7d0b00c: and r3, r1, r12
0xf7d0b010: ubfx r1, r0, #0, #2 <--- Should be "ubfx r1, r1, 16,
8"
0xf7d0b014: orr r1, r1, r3
0xf7d0b018: str r1, [r0, r2, lsl #2]
0xf7d0b01c: bx lr
This is similar to Bug 7222 where ARM::BFC and ARM::BFI are not implemented.
Similarly, straight from ARM's Architecture Reference Manual: A8.6.154 SBFX and
A.8.6.236 UBFX, ARMCodeEmitter.cpp should follow the BFC section with:
} else if ((TID.Opcode == ARM::UBFX) || (TID.Opcode == ARM::SBFX)) {
// Encode Rn in Insts[0-3]
Binary |= getMachineOpValue(MI, OpIdx++) << 0;
uint32_t lsb = MI.getOperand(OpIdx++).getImm();
uint32_t widthm1 = MI.getOperand(OpIdx++).getImm() - 1;
// Insts[20-16] = widthm1, Insts[11-7] = lsb
Binary |= (widthm1 & 0x1F) << 16;
Binary |= (lsb & 0x1F) << 7;
emitWordLE(Binary);
return;
}
This will fix the bug.
--
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