[LLVMdev] SCCP

Nick Lewycky nicholas at mxc.ca
Tue May 9 21:00:19 PDT 2006


Chris Lattner wrote:
> On Tue, 9 May 2006, Nick Lewycky wrote:
> 
>>> You could do that, but SCCPSolver isn't really useful to mainline LLVM
>>> for anything other than SCCP and IPSCCP, so we don't need it in a public
>>> header.  Out of curiosity, what are you looking to use the latice values
>>> for?  Why not just run SCCP and then look at the transformed code?
>>
>> I was planning to write an analysis pass that checks the expression at
>> every conditional statement to see whether the value is underdefined or
>> not.
> 
> Then just run the SCCP pass, and check to see if any operands satisfy
> the predicate "isa<UndefValue>(V)".  LLVM explicitly represents
> undefined values.

I have a case where it doesn't, but perhaps the SCCP pass isn't to blame:

  extern void write_char(int);

  const char foo[4] = "foo";

  write_char(foo[0]);
  write_char(foo[5]);

The write_char(foo[0]) correctly becomes write_char('f'), but the
write_char(foo[5]) doesn't become undefined, instead staying as a
GetElementPtrInst. I thought this might be because the optimizer is
being conservative about correctness, but that the lattice must still
show it as underdefined -- but obviously as I haven't looked at the
lattice directly, I haven't verified that yet.

Maybe it becomes overdefined as the constant can't be resolved, and I
should just fix the SCCP pass?

Nick




More information about the llvm-dev mailing list