[LLVMdev] ConstantFold 'undef xor undef'
jianzhou at seas.upenn.edu
Wed Jul 7 08:45:43 PDT 2010
On Wed, Jul 7, 2010 at 11:38 AM, Chris Lattner <clattner at apple.com> wrote:
> On Jul 7, 2010, at 5:47 AM, Jianzhou Zhao wrote:
>>> Does this also apply to two different variables? say
>>> int z x y;
>>> z = x ^ y;
>>> If ConstantFoldBinaryInstruction also folds x ^ y into z, should this
>>> pass (which uses ConstantFold) also initialize x and y with a same
>>> initial value? Otherwise at runtime z may not be 0.
>> I guess my question is what variables can have undef values. In my
>> understanding, only uninitialized locals and globals can be undefined,
>> so compilers are free to assign them at runtime, if
>> ConstantFoldBinaryInstruction ensures that x and y can only be locals
>> and globals. But function parameters cannot be undefined, which should
>> be arbitrary symbols, depending on concrete arguments. Is this
> I don't really understand your question here. Are you asking about C or LLVM IR, or something else?
Sorry for the confusion. Does ConstantFoldBinaryInstruction also fold
x ^ y into 0 if both x and y are undef? I can understand why x ^ x can
be 0 if x is undef, but if x and y are different variables, that x ^ y
= 0 must reply on the assumption that x and y need to be initialized
with the same value.
More information about the llvm-dev