PATCH + test for PR18032 (InstCombine issue)

Stepan Dyatkovskiy stpworld at
Fri Dec 20 03:45:56 PST 2013

Hi all,
Please find in attachment my PR18032 fix for review.

Issue description:
InstCombine Pass emits wrong alignment for 'load' instruction with 'null' as
Problem was in Local.cpp, llvm::getOrEnforceKnownAlignment method.
Method analyzes trailing zeroes in address values and suggest its own
For example: for address 0x123123a8 we have 3 binary trailing zeroes, and
thus, method will suggest you 8 bytes alignment.
Doing same logic, it will suggest you maximum possible alignment (2^29) for
'null' pointer.
Then InstCombiner::visitLoadInst method will select maximum alignment of 
was given in IR and what was suggested by getOrEnforceKnownAlignment; these
    if (KnownAlign > EffectiveLoadAlign)
So, finally we got align of 536870912 bytes:

The fix:
Add one more special case for getOrEnforceKnownAlignment. If address is 0,
we don't need to anylize trailing zeroes,
just return alignment known already (PrefAlign value).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr18032-2013-12-20.patch
Type: text/x-diff
Size: 2784 bytes
Desc: not available
URL: <>

More information about the llvm-commits mailing list