[llvm] [Hexagon] Set the offset of the memory operand for brev intrinsic (PR #212910)

Santanu Das via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 10:00:52 PDT 2026


================
@@ -1990,16 +1990,44 @@ static Value *returnEdge(const PHINode *PN, Value *IntrBaseVal) {
 // Bit-reverse Load Intrinsic: Figure out the underlying object the base
 // pointer points to, for the bit-reverse load intrinsic. Setting this to
 // memoperand might help alias analysis to figure out the dependencies.
-static Value *getUnderLyingObjectForBrevLdIntr(Value *V) {
+// A bit-reverse load accesses the base pointer with its low 16 bits reversed,
+// and post-increments the base pointer by the modifier value. For a chain of
+// bit-reverse loads, the offset that a load accesses relative to the
+// underlying object is the bit-reverse of the sum of the modifiers of the
+// preceding loads in the chain. Offset is set to that value, and HasOffset is
+// set to true, when the sum is known, that is when all of those modifiers are
+// constants and the sum fits in 16 unsigned bits. Otherwise HasOffset is set
+// to false and Offset is left unchanged.
+static Value *getUnderLyingObjectForBrevLdIntr(Value *V, int &Offset,
+                                               bool &HasOffset) {
   Value *IntrBaseVal = V;
   Value *BaseVal;
+  int64_t Sum = 0;
+  HasOffset = true;
----------------
quic-santdas wrote:

Probably good to change from HasOffset to something like isOffsetComputable. hasOffset=false gives the vibe that the offset is 0.

https://github.com/llvm/llvm-project/pull/212910


More information about the llvm-commits mailing list