[llvm] [DebugInfo][LoopVectorizer] Avoid dropping !dbg in optimizeForVFAndUF (PR #114243)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 30 14:19:18 PDT 2024


================
@@ -0,0 +1,108 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S < %s -passes=loop-vectorize -force-vector-width=2 | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define fastcc i32 @foo(i64 %a) {
+; CHECK-LABEL: define fastcc i32 @foo(
+; CHECK-SAME: i64 [[A:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*]]:
+; CHECK-NEXT:    [[WIDE_TRIP_COUNT:%.*]] = and i64 [[A]], 1
+; CHECK-NEXT:    [[TMP0:%.*]] = add nuw nsw i64 [[WIDE_TRIP_COUNT]], 1
+; CHECK-NEXT:    br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]
+; CHECK:       [[VECTOR_PH]]:
+; CHECK-NEXT:    [[N_RND_UP:%.*]] = add i64 [[TMP0]], 1
+; CHECK-NEXT:    [[N_MOD_VF:%.*]] = urem i64 [[N_RND_UP]], 2
+; CHECK-NEXT:    [[N_VEC:%.*]] = sub i64 [[N_RND_UP]], [[N_MOD_VF]]
+; CHECK-NEXT:    [[TRIP_COUNT_MINUS_1:%.*]] = sub i64 [[TMP0]], 1
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT1:%.*]] = insertelement <2 x i64> poison, i64 [[TRIP_COUNT_MINUS_1]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT2:%.*]] = shufflevector <2 x i64> [[BROADCAST_SPLATINSERT1]], <2 x i64> poison, <2 x i32> zeroinitializer
+; CHECK-NEXT:    br label %[[VECTOR_BODY:.*]]
+; CHECK:       [[VECTOR_BODY]]:
+; CHECK-NEXT:    [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[PRED_STORE_CONTINUE4:.*]] ], !dbg [[DBG4:![0-9]+]]
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <2 x i64> poison, i64 [[INDEX]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <2 x i64> [[BROADCAST_SPLATINSERT]], <2 x i64> poison, <2 x i32> zeroinitializer
+; CHECK-NEXT:    [[VEC_IV:%.*]] = add <2 x i64> [[BROADCAST_SPLAT]], <i64 0, i64 1>
+; CHECK-NEXT:    [[TMP1:%.*]] = icmp ule <2 x i64> [[VEC_IV]], [[BROADCAST_SPLAT2]]
+; CHECK-NEXT:    [[TMP2:%.*]] = extractelement <2 x i1> [[TMP1]], i32 0
+; CHECK-NEXT:    br i1 [[TMP2]], label %[[PRED_STORE_IF:.*]], label %[[PRED_STORE_CONTINUE:.*]]
+; CHECK:       [[PRED_STORE_IF]]:
+; CHECK-NEXT:    [[TMP3:%.*]] = trunc i64 0 to i8, !dbg [[DBG8:![0-9]+]]
+; CHECK-NEXT:    store i8 [[TMP3]], ptr null, align 1, !dbg [[DBG9:![0-9]+]]
+; CHECK-NEXT:    br label %[[PRED_STORE_CONTINUE]]
+; CHECK:       [[PRED_STORE_CONTINUE]]:
+; CHECK-NEXT:    [[TMP4:%.*]] = extractelement <2 x i1> [[TMP1]], i32 1, !dbg [[DBG9]]
+; CHECK-NEXT:    br i1 [[TMP4]], label %[[PRED_STORE_IF3:.*]], label %[[PRED_STORE_CONTINUE4]], !dbg [[DBG9]]
+; CHECK:       [[PRED_STORE_IF3]]:
+; CHECK-NEXT:    [[TMP5:%.*]] = trunc i64 0 to i8, !dbg [[DBG8]]
+; CHECK-NEXT:    store i8 [[TMP5]], ptr null, align 1, !dbg [[DBG9]]
+; CHECK-NEXT:    br label %[[PRED_STORE_CONTINUE4]], !dbg [[DBG9]]
+; CHECK:       [[PRED_STORE_CONTINUE4]]:
+; CHECK-NEXT:    [[INDEX_NEXT]] = add i64 [[INDEX]], 2, !dbg [[DBG4]]
+; CHECK-NEXT:    br i1 true, label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !dbg [[DBG4]], !llvm.loop [[LOOP10:![0-9]+]]
+; CHECK:       [[MIDDLE_BLOCK]]:
+; CHECK-NEXT:    br i1 true, label %[[DO_BODY45_PREHEADER:.*]], label %[[SCALAR_PH]], !dbg [[DBG13:![0-9]+]]
+; CHECK:       [[SCALAR_PH]]:
+; CHECK-NEXT:    [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ], !dbg [[DBG4]]
+; CHECK-NEXT:    br label %[[DO_BODY:.*]]
+; CHECK:       [[DO_BODY]]:
+; CHECK-NEXT:    [[INDVARS_IV554:%.*]] = phi i64 [ [[INDVARS_IV_NEXT555:%.*]], %[[DO_BODY]] ], [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], !dbg [[DBG4]]
+; CHECK-NEXT:    [[CONV39:%.*]] = trunc i64 0 to i8, !dbg [[DBG8]]
+; CHECK-NEXT:    store i8 [[CONV39]], ptr null, align 1, !dbg [[DBG9]]
+; CHECK-NEXT:    [[INDVARS_IV_NEXT555]] = add i64 [[INDVARS_IV554]], 1, !dbg [[DBG14:![0-9]+]]
+; CHECK-NEXT:    [[EXITCOND557_NOT:%.*]] = icmp eq i64 [[INDVARS_IV554]], [[WIDE_TRIP_COUNT]], !dbg [[DBG15:![0-9]+]]
+; CHECK-NEXT:    br i1 [[EXITCOND557_NOT]], label %[[DO_BODY45_PREHEADER]], label %[[DO_BODY]], !dbg [[DBG13]], !llvm.loop [[LOOP16:![0-9]+]]
+; CHECK:       [[DO_BODY45_PREHEADER]]:
+; CHECK-NEXT:    ret i32 0
+;
+entry:
+  %wide.trip.count = and i64 %a, 1
+  br label %do.body
+
+do.body:                                          ; preds = %do.body, %entry
+  %indvars.iv554 = phi i64 [ %indvars.iv.next555, %do.body ], [ 0, %entry ], !dbg !4
+  %conv39 = trunc i64 0 to i8, !dbg !5
+  store i8 %conv39, ptr null, align 1, !dbg !6
+  %indvars.iv.next555 = add i64 %indvars.iv554, 1, !dbg !7
+  %exitcond557.not = icmp eq i64 %indvars.iv554, %wide.trip.count, !dbg !8
+  br i1 %exitcond557.not, label %do.body45.preheader, label %do.body, !dbg !9
+
+do.body45.preheader:                              ; preds = %do.body
+  ret i32 0
----------------
fhahn wrote:

```suggestion
exit: 
  ret void
```

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


More information about the llvm-commits mailing list