Recursive computeKnownBits initiates parameters KnownZero and KnownOne
at the begining so we should use KnownZero2 and KnownOne2.
We should use computation for returned Known bits.
Despite of the comments, isPowerOf2 returns true for RA is power of two = 0, i.e. RA = 1,
Details
Diff Detail
Event Timeline
LGTM with a code nit and a test change.
lib/CodeGen/SelectionDAG/SelectionDAG.cpp | ||
---|---|---|
2198 | This assignment is redundant. How about just // The upper bits are all zero, the lower ones are unchanged. | |
test/CodeGen/Generic/computeKnownBits_urem.ll | ||
1 | This should probably also check the generated assembly. It is fine to move it to a cpu specific directory and use a -mtriple. |
I check asm output in new version by
llc -mtriple=i386-pc-win32 computeKnownBits_urem.ll
Result is very simple and right:
_main: # @main # BB#0: # %entry pushl %eax movl $1, (%esp) movl $1, %eax popl %edx retl
Algorithm is sufficiently complex and the same result in asm
can be obtained by the different ways with slightly different IR file.
Changed code works when simplification begins from not "urem" instruction.
Instructions "and" and "or" set KnownOne and KnownZero mutually.
Instruction "load" in computeKnownBits cuts initialization of %a.
Result of changed code work is simplification with message
Replacing.2 .......
if KnownOne and KnownZero leads to definite result
then next message is
With: 0x{{[0-9a-f]+}}: i32 = Constant ....
Sorry, I missed this.
I committed the patch (r209902 ). I just updated the test to check for
assembly (as opposed to just generating it).
Normally in LLVM we test that the result is valid, not exactly the
steps that a transformation is doing. Doing that gives more freedom at
modifying the passes in the future.
We do try to write small tests and test the smallest part of llvm that
we can. It is really unfortunate with codegen that such a large piece
of code needs to be run, but I don't think that checking deubg output
is the correct way to fix that.
This assignment is redundant. How about just
// The upper bits are all zero, the lower ones are unchanged.
KnownOne = KnownOne2 & LowBits;
KnownZero = KnowZero2 | ~LowBits;