[llvm] [VPlan] Hoist loads with invariant addresses using noalias metadata. (PR #166247)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 4 05:56:26 PST 2025


================
@@ -156,15 +156,15 @@ define void @trunc_store(ptr %dst, ptr %src, i16 %x) #1 {
 ; DEFAULT-NEXT:    [[VEC_EPILOG_RESUME_VAL:%.*]] = phi i64 [ 992, [[VEC_EPILOG_ITER_CHECK]] ], [ 0, [[VECTOR_MAIN_LOOP_ITER_CHECK]] ]
 ; DEFAULT-NEXT:    [[BROADCAST_SPLATINSERT4:%.*]] = insertelement <8 x i16> poison, i16 [[X]], i64 0
 ; DEFAULT-NEXT:    [[BROADCAST_SPLAT5:%.*]] = shufflevector <8 x i16> [[BROADCAST_SPLATINSERT4]], <8 x i16> poison, <8 x i32> zeroinitializer
-; DEFAULT-NEXT:    [[TMP7:%.*]] = trunc <8 x i16> [[BROADCAST_SPLAT5]] to <8 x i8>
-; DEFAULT-NEXT:    br label [[VEC_EPILOG_VECTOR_BODY:%.*]]
-; DEFAULT:       vec.epilog.vector.body:
----------------
fhahn wrote:

It should only ever do the transformation using noalias metadata (the pointer of MemoryLocation is set to nullptr, so cannot be used to determine noalias).

The way the diff is highligthed here makes it a bit difficult to see, but we hoist `[TMP8:%.*]] = load i64, ptr [[SRC]], align 8, !alias.scope [[META6]]` together with some instructions used by it.

The only store in the loop ( `store <8 x i8> [[TMP10]], ptr [[TMP11]], align 1, !alias.scope [[META9]], !noalias [[META6]] `) also has noalias metadata not aliasing the load

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


More information about the llvm-commits mailing list