Different index types in GEPs -> non-aliasing?

Hi,

It seems that opt thinks that the two pointers

  %_tmp2 = getelementptr [3 x i16], [3 x i16]* %a, i16 0, i64 1
and
  %_tmp4 = getelementptr [3 x i16], [3 x i16]* %a, i16 0, i16 1

does not alias? Is this intended or a bug?

Details below:

This sounds like a bug to me.

// If the last (struct) indices are constants and are equal, the other indices
// might be also be dynamically equal, so the GEPs can alias.
if (C1 && C2 && C1 == C2)
   return MayAlias;

Does changing this condition fix the issue? E.g

  if (C1 && C2 && C1->getSExtValue() == C2->getSExtValue()) { ... }

best
vedant

Hi,

This sounds like a bug to me.

  // If the last (struct) indices are constants and are equal, the other indices
  // might be also be dynamically equal, so the GEPs can alias.
  if (C1 && C2 && C1 == C2)
    return MayAlias;

Does changing this condition fix the issue? E.g

   if (C1 && C2 && C1->getSExtValue() == C2->getSExtValue()) { ... }

Yes it does. Then it realize the two GEPs alias and I get the expected result.

But since there is also a Value pointer comparison in

bool BasicAAResult::isValueEqualInPotentialCycles(const Value *V,
                                                   const Value *V2) {
   if (V != V2)
     return false;

and probably in several other places too I wasn't comfortable just changing it... Right now I made my front-end always use i64 for GEP array indices instead.

Should I file a bugzilla report on this?

Regards,
Mikael

Hi,

This sounds like a bug to me.

// If the last (struct) indices are constants and are equal, the other indices
// might be also be dynamically equal, so the GEPs can alias.
if (C1 && C2 && C1 == C2)
   return MayAlias;

Does changing this condition fix the issue? E.g

  if (C1 && C2 && C1->getSExtValue() == C2->getSExtValue()) { ... }

Yes it does. Then it realize the two GEPs alias and I get the expected result.

But since there is also a Value pointer comparison in

bool BasicAAResult::isValueEqualInPotentialCycles(const Value *V,
                                                 const Value *V2) {
if (V != V2)
   return false;

and probably in several other places too I wasn't comfortable just changing it... Right now I made my front-end always use i64 for GEP array indices instead.

Yes, I think it'd be best to open up a bug for this.

thanks
vedant

Hi,