[LLVMbugs] [Bug 11485] New: Division by power of two expansion blocked by other flag
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Dec 5 17:46:27 PST 2011
http://llvm.org/bugs/show_bug.cgi?id=11485
Bug #: 11485
Summary: Division by power of two expansion blocked by other
flag
Product: libraries
Version: trunk
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
AssignedTo: unassignedbugs at nondot.org
ReportedBy: javier.e.martinez at intel.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 7675
--> http://llvm.org/bugs/attachment.cgi?id=7675
Fix for expanding integer division by 2
Assume that a target can do integer division cheaply but not as cheap as
shifts. This target would call setIntDivIsCheap(true) and
setPow2DivIsCheap(false). The issue is that the DAGCombiner visitSDIV punts if
isIntDivCheap is true. The fix is to check for isPow2DivCheap instead. Below is
the current code and the fix. A patch is also attached.
[CURRENT]
// fold (sdiv X, pow2) -> simple ops after legalize
if (N1C && !N1C->isNullValue() && !TLI.isIntDivCheap() &&
(N1C->getAPIntValue().isPowerOf2() ||
(-N1C->getAPIntValue()).isPowerOf2())) {
// If dividing by powers of two is cheap, then don't perform the following
// fold.
if (TLI.isPow2DivCheap())
return SDValue();
unsigned lg2 = N1C->getAPIntValue().countTrailingZeros();
[FIX]
// fold (sdiv X, pow2) -> simple ops after legalize
if (N1C && !N1C->isNullValue() && !TLI.isPow2DivCheap() &&
(N1C->getAPIntValue().isPowerOf2() ||
(-N1C->getAPIntValue()).isPowerOf2())) {
unsigned lg2 = N1C->getAPIntValue().countTrailingZeros();
--
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