0

I am writing llvm code using C++. I have a place in my code where the below scenario happens

 1. %117 = phi <2 x double>* [ %105, %aligned ], [ %159, %116 ]
 7. %123 = getelementptr <2 x double>* %117, i32 0
 8. %127 = getelementptr <2 x double>* %123, i32 0
 9. %128 = load <2 x double>* %127
10. %129 = getelementptr <2 x double>* %123, i32 1
11. %130 = load <2 x double>* %129
12. %131 = shufflevector <2 x double> %128, <2 x double> %130, <2 x i32> <i32 1, i32 3>

I am trying to compute the same address which should point to same data type twice in lines 7 and 8 with the address parameter value different. Is it safe to do this or will this lead to undefined results?

Kaniks
  • 277
  • 1
  • 4
  • 8

1 Answers1

0

The instruction

%x = getelementptr %anytype* %y, i32 0

Is completely meaningless; it's as if you've written (the illegal):

%x = %y

So yes, both %123 and %127 will point to the same memory. It's safe, but redundant: you can just use %117 directly wherever %123 or %127 are used. The only problematic thing in your snippet is that the value numbering is not sequential, but I assume that's just from pasting just parts of the code here.

Oak
  • 26,231
  • 8
  • 93
  • 152