[llvm] [LV] Update test to not have trivially simplify-able/dead instrs (NFC) (PR #195136)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 30 10:46:27 PDT 2026
https://github.com/fhahn created https://github.com/llvm/llvm-project/pull/195136
Make a few tests more robust w.r.t. simplifications/DCE by adding users and adjust a trivially simplify-able AND.
>From f4e43808aebb2b07df509101c6cb32c0113e913d Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Thu, 30 Apr 2026 17:37:09 +0100
Subject: [PATCH] [LV] Update test to not have trivially simplify-able/dead
instrs (NFC)
Make a few tests more robust w.r.t. simplifications/DCE by adding users
and adjust a trivially simplify-able AND.
---
.../X86/cost-constant-known-via-scev.ll | 8 ++-
.../Transforms/LoopVectorize/X86/funclet.ll | 56 ++++++++++++++-----
2 files changed, 48 insertions(+), 16 deletions(-)
diff --git a/llvm/test/Transforms/LoopVectorize/X86/cost-constant-known-via-scev.ll b/llvm/test/Transforms/LoopVectorize/X86/cost-constant-known-via-scev.ll
index bf3ff15236038..dbf1eaea669b7 100644
--- a/llvm/test/Transforms/LoopVectorize/X86/cost-constant-known-via-scev.ll
+++ b/llvm/test/Transforms/LoopVectorize/X86/cost-constant-known-via-scev.ll
@@ -75,12 +75,14 @@ define i64 @second_lshr_operand_zero_via_scev() {
; CHECK-NEXT: [[STEP_ADD4:%.*]] = add <2 x i32> [[VEC_IND2]], splat (i32 2)
; CHECK-NEXT: [[TMP0:%.*]] = icmp eq <2 x i64> [[VEC_IND]], zeroinitializer
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i64> [[STEP_ADD]], zeroinitializer
+; CHECK-NEXT: [[TMP2:%.*]] = and <2 x i64> [[VEC_IND]], splat (i64 3)
+; CHECK-NEXT: [[TMP3:%.*]] = and <2 x i64> [[STEP_ADD]], splat (i64 3)
; CHECK-NEXT: [[TMP4:%.*]] = lshr <2 x i32> [[VEC_IND2]], zeroinitializer
; CHECK-NEXT: [[TMP5:%.*]] = lshr <2 x i32> [[STEP_ADD4]], zeroinitializer
; CHECK-NEXT: [[TMP6:%.*]] = zext <2 x i32> [[TMP4]] to <2 x i64>
; CHECK-NEXT: [[TMP7:%.*]] = zext <2 x i32> [[TMP5]] to <2 x i64>
-; CHECK-NEXT: [[TMP8:%.*]] = select <2 x i1> [[TMP0]], <2 x i64> zeroinitializer, <2 x i64> [[TMP6]]
-; CHECK-NEXT: [[TMP9:%.*]] = select <2 x i1> [[TMP1]], <2 x i64> zeroinitializer, <2 x i64> [[TMP7]]
+; CHECK-NEXT: [[TMP8:%.*]] = select <2 x i1> [[TMP0]], <2 x i64> [[TMP2]], <2 x i64> [[TMP6]]
+; CHECK-NEXT: [[TMP9:%.*]] = select <2 x i1> [[TMP1]], <2 x i64> [[TMP3]], <2 x i64> [[TMP7]]
; CHECK-NEXT: [[TMP10]] = or <2 x i64> [[TMP8]], [[VEC_PHI]]
; CHECK-NEXT: [[TMP11]] = or <2 x i64> [[TMP9]], [[VEC_PHI1]]
; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
@@ -103,7 +105,7 @@ loops:
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loops ]
%red = phi i64 [ 0, %entry ], [ %red.next, %loops ]
%c = icmp eq i64 %iv, 0
- %and = and i64 %iv, 0
+ %and = and i64 %iv, 3
%0 = trunc i64 %iv to i32
%shr = lshr i32 %0, %ext.0
%conv.1 = zext i32 %shr to i64
diff --git a/llvm/test/Transforms/LoopVectorize/X86/funclet.ll b/llvm/test/Transforms/LoopVectorize/X86/funclet.ll
index 2ccb0428b9269..58812b5e2309d 100644
--- a/llvm/test/Transforms/LoopVectorize/X86/funclet.ll
+++ b/llvm/test/Transforms/LoopVectorize/X86/funclet.ll
@@ -1,28 +1,62 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals none --version 6
; RUN: opt -S -passes=loop-vectorize < %s | FileCheck %s
+
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc18.0.0"
+ at sink = external global double
+
define void @test1() #0 personality ptr @__CxxFrameHandler3 {
+; CHECK-LABEL: define void @test1(
+; CHECK-SAME: ) #[[ATTR0:[0-9]+]] personality ptr @__CxxFrameHandler3 {
+; CHECK-NEXT: [[ENTRY:.*:]]
+; CHECK-NEXT: invoke void @_CxxThrowException(ptr null, ptr null)
+; CHECK-NEXT: to label %[[UNREACHABLE:.*]] unwind label %[[CATCH_DISPATCH:.*]]
+; CHECK: [[CATCH_DISPATCH]]:
+; CHECK-NEXT: [[TMP0:%.*]] = catchswitch within none [label %[[CATCH:.*]]] unwind to caller
+; CHECK: [[CATCH]]:
+; CHECK-NEXT: [[TMP1:%.*]] = catchpad within [[TMP0]] [ptr null, i32 64, ptr null]
+; CHECK-NEXT: br label %[[FOR_BODY:.*]]
+; CHECK: [[FOR_BODY]]:
+; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
+; CHECK: [[VECTOR_BODY]]:
+; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[FOR_BODY]] ], [ [[INC:%.*]], %[[VECTOR_BODY]] ]
+; CHECK-NEXT: [[TMP2:%.*]] = call <16 x double> @llvm.floor.v16f64(<16 x double> splat (double 1.000000e+00)) [ "funclet"(token [[TMP1]]) ]
+; CHECK-NEXT: [[INC]] = add nuw i32 [[INDEX]], 16
+; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[INC]], 1024
+; CHECK-NEXT: br i1 [[EXITCOND]], label %[[TRY_CONT:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
+; CHECK: [[TRY_CONT]]:
+; CHECK-NEXT: [[TMP4:%.*]] = extractelement <16 x double> [[TMP2]], i64 15
+; CHECK-NEXT: br label %[[EXIT:.*]]
+; CHECK: [[EXIT]]:
+; CHECK-NEXT: store double [[TMP4]], ptr @sink, align 8
+; CHECK-NEXT: catchret from [[TMP1]] to label %[[TRY_CONT1:.*]]
+; CHECK: [[TRY_CONT1]]:
+; CHECK-NEXT: ret void
+; CHECK: [[UNREACHABLE]]:
+; CHECK-NEXT: unreachable
+;
entry:
invoke void @_CxxThrowException(ptr null, ptr null)
- to label %unreachable unwind label %catch.dispatch
+ to label %unreachable unwind label %catch.dispatch
catch.dispatch:
%0 = catchswitch within none [label %catch] unwind to caller
catch:
%1 = catchpad within %0 [ptr null, i32 64, ptr null]
- br label %for.body
-
-for.cond.cleanup:
- catchret from %1 to label %try.cont
+ br label %loop
-for.body:
- %i.07 = phi i32 [ 0, %catch ], [ %inc, %for.body ]
+loop:
+ %iv = phi i32 [ 0, %catch ], [ %inc, %loop ]
%call = call double @floor(double 1.0) #1 [ "funclet"(token %1) ]
- %inc = add nuw nsw i32 %i.07, 1
+ %inc = add nuw nsw i32 %iv, 1
%exitcond = icmp eq i32 %inc, 1024
- br i1 %exitcond, label %for.cond.cleanup, label %for.body
+ br i1 %exitcond, label %exit, label %loop
+
+exit:
+ store double %call, ptr @sink
+ catchret from %1 to label %try.cont
try.cont:
ret void
@@ -31,10 +65,6 @@ unreachable:
unreachable
}
-; CHECK-LABEL: define void @test1(
-; CHECK: %[[cpad:.*]] = catchpad within {{.*}} [ptr null, i32 64, ptr null]
-; CHECK: call <16 x double> @llvm.floor.v16f64(<16 x double> {{.*}}) [ "funclet"(token %[[cpad]]) ]
-
declare x86_stdcallcc void @_CxxThrowException(ptr, ptr)
declare i32 @__CxxFrameHandler3(...)
More information about the llvm-commits
mailing list