Skip to content

Commit 152ed59

Browse files
[NFC][LLVM][Tests] Add RUN lines to verify Constant{Int/FP} based splats.
llvm/test/Transforms/Attributor/nofpclass.ll llvm/test/Transforms/InstCombine/exact.ll llvm/test/Transforms/InstCombine/load-store-forward.ll llvm/test/Transforms/SCCP/overdefined-ext.ll
1 parent 4c16cff commit 152ed59

File tree

4 files changed

+91
-42
lines changed

4 files changed

+91
-42
lines changed

llvm/test/Transforms/Attributor/nofpclass.ll

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes --version 2
2-
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3-
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
2+
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -use-constant-fp-for-scalable-splat=false -S < %s | FileCheck %s --check-prefixes=CHECK,CHECK-CV,TUNIT,TUNIT-CV
3+
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -use-constant-fp-for-scalable-splat=false -S < %s | FileCheck %s --check-prefixes=CHECK,CHECK-CV,CGSCC,CGSCC-CV
4+
5+
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -use-constant-fp-for-scalable-splat -S < %s | FileCheck %s --check-prefixes=CHECK,CHECK-CI,TUNIT,TUNIT-CI
6+
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -use-constant-fp-for-scalable-splat -S < %s | FileCheck %s --check-prefixes=CHECK,CHECK-CI,CGSCC,CGSCC-CI
47

58
declare nofpclass(nan) float @ret_nofpclass_nan()
69
declare [2 x [3 x float]] @ret_array()
@@ -2468,7 +2471,7 @@ define internal float @through_memory0(ptr %ptr.arg) {
24682471
; CGSCC-SAME: (float [[TMP0:%.*]]) #[[ATTR3]] {
24692472
; CGSCC-NEXT: [[PTR_ARG_PRIV:%.*]] = alloca float, align 4
24702473
; CGSCC-NEXT: store float [[TMP0]], ptr [[PTR_ARG_PRIV]], align 4
2471-
; CGSCC-NEXT: [[LOAD:%.*]] = load float, ptr [[PTR_ARG_PRIV]], align 4
2474+
; CGSCC-NEXT: [[LOAD:%.*]] = load float, ptr [[PTR_ARG_PRIV]], align 4, !invariant.load [[META0:![0-9]+]]
24722475
; CGSCC-NEXT: ret float [[LOAD]]
24732476
;
24742477
%load = load float, ptr %ptr.arg
@@ -2491,7 +2494,7 @@ define internal float @through_memory1(ptr %ptr.arg) {
24912494
; CGSCC-SAME: (float [[TMP0:%.*]]) #[[ATTR3]] {
24922495
; CGSCC-NEXT: [[PTR_ARG_PRIV:%.*]] = alloca float, align 4
24932496
; CGSCC-NEXT: store float [[TMP0]], ptr [[PTR_ARG_PRIV]], align 4
2494-
; CGSCC-NEXT: [[LOAD:%.*]] = load float, ptr [[PTR_ARG_PRIV]], align 4
2497+
; CGSCC-NEXT: [[LOAD:%.*]] = load float, ptr [[PTR_ARG_PRIV]], align 4, !invariant.load [[META0]]
24952498
; CGSCC-NEXT: [[CALL:%.*]] = call float @llvm.arithmetic.fence.f32(float [[LOAD]]) #[[ATTR19]]
24962499
; CGSCC-NEXT: ret float [[CALL]]
24972500
;
@@ -2507,7 +2510,7 @@ define internal float @through_memory2(ptr %ptr.arg) {
25072510
; CHECK-SAME: (float [[TMP0:%.*]]) #[[ATTR15:[0-9]+]] {
25082511
; CHECK-NEXT: [[PTR_ARG_PRIV:%.*]] = alloca float, align 4
25092512
; CHECK-NEXT: store float [[TMP0]], ptr [[PTR_ARG_PRIV]], align 4
2510-
; CHECK-NEXT: [[LOAD:%.*]] = load float, ptr [[PTR_ARG_PRIV]], align 4
2513+
; CHECK-NEXT: [[LOAD:%.*]] = load float, ptr [[PTR_ARG_PRIV]], align 4, !invariant.load [[META0:![0-9]+]]
25112514
; CHECK-NEXT: [[CALL:%.*]] = call float @extern.f32(float [[LOAD]])
25122515
; CHECK-NEXT: ret float [[CALL]]
25132516
;
@@ -2664,10 +2667,15 @@ define [4 x float] @constant_aggregate_zero() {
26642667
}
26652668

26662669
define <vscale x 4 x float> @scalable_splat_pnorm() {
2667-
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
2668-
; CHECK-LABEL: define noundef <vscale x 4 x float> @scalable_splat_pnorm
2669-
; CHECK-SAME: () #[[ATTR3]] {
2670-
; CHECK-NEXT: ret <vscale x 4 x float> splat (float 1.000000e+00)
2670+
; CHECK-CV: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
2671+
; CHECK-CV-LABEL: define noundef <vscale x 4 x float> @scalable_splat_pnorm
2672+
; CHECK-CV-SAME: () #[[ATTR3]] {
2673+
; CHECK-CV-NEXT: ret <vscale x 4 x float> splat (float 1.000000e+00)
2674+
;
2675+
; CHECK-CI: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
2676+
; CHECK-CI-LABEL: define noundef nofpclass(nan inf zero sub nnorm) <vscale x 4 x float> @scalable_splat_pnorm
2677+
; CHECK-CI-SAME: () #[[ATTR3]] {
2678+
; CHECK-CI-NEXT: ret <vscale x 4 x float> splat (float 1.000000e+00)
26712679
;
26722680
ret <vscale x 4 x float> splat (float 1.0)
26732681
}
@@ -2978,3 +2986,8 @@ attributes #2 = { "denormal-fp-math"="ieee,preserve-sign" }
29782986
attributes #3 = { "denormal-fp-math"="positive-zero,positive-zero" }
29792987
attributes #4 = { "denormal-fp-math"="positive-zero,ieee" }
29802988
attributes #5 = { "denormal-fp-math"="ieee,positive-zero" }
2989+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
2990+
; CGSCC-CI: {{.*}}
2991+
; CGSCC-CV: {{.*}}
2992+
; TUNIT-CI: {{.*}}
2993+
; TUNIT-CV: {{.*}}

llvm/test/Transforms/InstCombine/exact.ll

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
2+
; RUN: opt < %s -passes=instcombine -use-constant-int-for-fixed-length-splat=false -S | FileCheck %s --check-prefixes=CHECK,CHECK-CV
3+
; RUN: opt < %s -passes=instcombine -use-constant-int-for-fixed-length-splat -S | FileCheck %s --check-prefixes=CHECK,CHECK-CI
34

45
define i32 @sdiv1(i32 %x) {
56
; CHECK-LABEL: @sdiv1(
@@ -162,12 +163,16 @@ define i1 @pr9998(i32 %V) {
162163

163164
; FIXME: Vectors should fold the same way.
164165
define <2 x i1> @pr9998vec(<2 x i32> %V) {
165-
; CHECK-LABEL: @pr9998vec(
166-
; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i32> [[V:%.*]], splat (i32 1)
167-
; CHECK-NEXT: [[X:%.*]] = sub nsw <2 x i32> zeroinitializer, [[TMP1]]
168-
; CHECK-NEXT: [[Y:%.*]] = sext <2 x i32> [[X]] to <2 x i64>
169-
; CHECK-NEXT: [[Z:%.*]] = icmp ugt <2 x i64> [[Y]], splat (i64 7297771788697658747)
170-
; CHECK-NEXT: ret <2 x i1> [[Z]]
166+
; CHECK-CV-LABEL: @pr9998vec(
167+
; CHECK-CV-NEXT: [[TMP1:%.*]] = and <2 x i32> [[V:%.*]], splat (i32 1)
168+
; CHECK-CV-NEXT: [[X:%.*]] = sub nsw <2 x i32> zeroinitializer, [[TMP1]]
169+
; CHECK-CV-NEXT: [[Y:%.*]] = sext <2 x i32> [[X]] to <2 x i64>
170+
; CHECK-CV-NEXT: [[Z:%.*]] = icmp ugt <2 x i64> [[Y]], splat (i64 7297771788697658747)
171+
; CHECK-CV-NEXT: ret <2 x i1> [[Z]]
172+
;
173+
; CHECK-CI-LABEL: @pr9998vec(
174+
; CHECK-CI-NEXT: [[Z:%.*]] = trunc <2 x i32> [[V:%.*]] to <2 x i1>
175+
; CHECK-CI-NEXT: ret <2 x i1> [[Z]]
171176
;
172177
%W = shl <2 x i32> %V, <i32 31, i32 31>
173178
%X = ashr exact <2 x i32> %W, <i32 31, i32 31>

llvm/test/Transforms/InstCombine/load-store-forward.ll

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt -S -passes=instcombine < %s | FileCheck %s --check-prefixes=CHECK,LITTLE
3-
; RUN: opt -S -passes=instcombine -data-layout="E" < %s | FileCheck %s --check-prefixes=CHECK,BIG
2+
; RUN: opt -S -passes=instcombine -use-constant-int-for-scalable-splat=false -use-constant-fp-for-scalable-splat=false < %s | FileCheck %s --check-prefixes=CHECK,CHECK-CV,LITTLE,LITTLE-CV
3+
; RUN: opt -S -passes=instcombine -use-constant-int-for-scalable-splat -use-constant-fp-for-scalable-splat < %s | FileCheck %s --check-prefixes=CHECK,CHECK-CI,LITTLE,LITTLE-CI
4+
; RUN: opt -S -passes=instcombine -data-layout="E" -use-constant-int-for-scalable-splat=false -use-constant-fp-for-scalable-splat=false < %s | FileCheck %s --check-prefixes=CHECK,CHECK-CV,BIG,BIG-CV
5+
; RUN: opt -S -passes=instcombine -data-layout="E" -use-constant-int-for-scalable-splat -use-constant-fp-for-scalable-splat < %s | FileCheck %s --check-prefixes=CHECK,CHECK-CI,BIG,BIG-CI
46

57
define i8 @load_smaller_int(ptr %p) {
68
; LITTLE-LABEL: @load_smaller_int(
@@ -101,11 +103,16 @@ define i32 @vec_store_load_overlap(ptr %p) {
101103
}
102104

103105
define i32 @load_i32_store_nxv4i32(ptr %a) {
104-
; CHECK-LABEL: @load_i32_store_nxv4i32(
105-
; CHECK-NEXT: entry:
106-
; CHECK-NEXT: store <vscale x 4 x i32> splat (i32 1), ptr [[A:%.*]], align 16
107-
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4
108-
; CHECK-NEXT: ret i32 [[TMP0]]
106+
; CHECK-CV-LABEL: @load_i32_store_nxv4i32(
107+
; CHECK-CV-NEXT: entry:
108+
; CHECK-CV-NEXT: store <vscale x 4 x i32> splat (i32 1), ptr [[A:%.*]], align 16
109+
; CHECK-CV-NEXT: [[TMP0:%.*]] = load i32, ptr [[A]], align 4
110+
; CHECK-CV-NEXT: ret i32 [[TMP0]]
111+
;
112+
; CHECK-CI-LABEL: @load_i32_store_nxv4i32(
113+
; CHECK-CI-NEXT: entry:
114+
; CHECK-CI-NEXT: store <vscale x 4 x i32> splat (i32 1), ptr [[A:%.*]], align 16
115+
; CHECK-CI-NEXT: ret i32 1
109116
;
110117
entry:
111118
store <vscale x 4 x i32> splat (i32 1), ptr %a, align 16
@@ -153,11 +160,16 @@ entry:
153160
}
154161

155162
define float @load_f32_store_nxv4f32(ptr %a) {
156-
; CHECK-LABEL: @load_f32_store_nxv4f32(
157-
; CHECK-NEXT: entry:
158-
; CHECK-NEXT: store <vscale x 4 x float> splat (float 1.000000e+00), ptr [[A:%.*]], align 16
159-
; CHECK-NEXT: [[TMP0:%.*]] = load float, ptr [[A]], align 4
160-
; CHECK-NEXT: ret float [[TMP0]]
163+
; CHECK-CV-LABEL: @load_f32_store_nxv4f32(
164+
; CHECK-CV-NEXT: entry:
165+
; CHECK-CV-NEXT: store <vscale x 4 x float> splat (float 1.000000e+00), ptr [[A:%.*]], align 16
166+
; CHECK-CV-NEXT: [[TMP0:%.*]] = load float, ptr [[A]], align 4
167+
; CHECK-CV-NEXT: ret float [[TMP0]]
168+
;
169+
; CHECK-CI-LABEL: @load_f32_store_nxv4f32(
170+
; CHECK-CI-NEXT: entry:
171+
; CHECK-CI-NEXT: store <vscale x 4 x float> splat (float 1.000000e+00), ptr [[A:%.*]], align 16
172+
; CHECK-CI-NEXT: ret float 1.000000e+00
161173
;
162174
entry:
163175
store <vscale x 4 x float> splat (float 1.0), ptr %a, align 16
@@ -166,11 +178,16 @@ entry:
166178
}
167179

168180
define i32 @load_i32_store_nxv4f32(ptr %a) {
169-
; CHECK-LABEL: @load_i32_store_nxv4f32(
170-
; CHECK-NEXT: entry:
171-
; CHECK-NEXT: store <vscale x 4 x float> splat (float 1.000000e+00), ptr [[A:%.*]], align 16
172-
; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr [[A]], align 4
173-
; CHECK-NEXT: ret i32 [[LOAD]]
181+
; CHECK-CV-LABEL: @load_i32_store_nxv4f32(
182+
; CHECK-CV-NEXT: entry:
183+
; CHECK-CV-NEXT: store <vscale x 4 x float> splat (float 1.000000e+00), ptr [[A:%.*]], align 16
184+
; CHECK-CV-NEXT: [[LOAD:%.*]] = load i32, ptr [[A]], align 4
185+
; CHECK-CV-NEXT: ret i32 [[LOAD]]
186+
;
187+
; CHECK-CI-LABEL: @load_i32_store_nxv4f32(
188+
; CHECK-CI-NEXT: entry:
189+
; CHECK-CI-NEXT: store <vscale x 4 x float> splat (float 1.000000e+00), ptr [[A:%.*]], align 16
190+
; CHECK-CI-NEXT: ret i32 1065353216
174191
;
175192
entry:
176193
store <vscale x 4 x float> splat (float 1.0), ptr %a, align 16
@@ -506,3 +523,8 @@ define <vscale x 1 x i32> @load_after_memset_0_scalable(ptr %a) {
506523
}
507524

508525
declare void @llvm.memset.p0.i64(ptr, i8, i64, i1)
526+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
527+
; BIG-CI: {{.*}}
528+
; BIG-CV: {{.*}}
529+
; LITTLE-CI: {{.*}}
530+
; LITTLE-CV: {{.*}}

llvm/test/Transforms/SCCP/overdefined-ext.ll

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt < %s -passes=sccp -S | FileCheck %s
2+
; RUN: opt < %s -passes=sccp -use-constant-int-for-fixed-length-splat=false -S | FileCheck %s --check-prefixes=CHECK,CHECK-CV
3+
; RUN: opt < %s -passes=sccp -use-constant-int-for-fixed-length-splat -S | FileCheck %s --check-prefixes=CHECK,CHECK-CI
34

45
define i32 @zext_lshr(i1 %t0) {
56
; CHECK-LABEL: @zext_lshr(
@@ -24,10 +25,14 @@ define i1 @zext_icmp(i1 %t0) {
2425
; TODO: SCCP operates poorly with vector ranges
2526

2627
define <2 x i1> @zext_vector(<2 x i1> %t0) {
27-
; CHECK-LABEL: @zext_vector(
28-
; CHECK-NEXT: [[T1:%.*]] = zext <2 x i1> [[T0:%.*]] to <2 x i32>
29-
; CHECK-NEXT: [[T2:%.*]] = icmp eq <2 x i32> [[T1]], splat (i32 2)
30-
; CHECK-NEXT: ret <2 x i1> [[T2]]
28+
; CHECK-CV-LABEL: @zext_vector(
29+
; CHECK-CV-NEXT: [[T1:%.*]] = zext <2 x i1> [[T0:%.*]] to <2 x i32>
30+
; CHECK-CV-NEXT: [[T2:%.*]] = icmp eq <2 x i32> [[T1]], splat (i32 2)
31+
; CHECK-CV-NEXT: ret <2 x i1> [[T2]]
32+
;
33+
; CHECK-CI-LABEL: @zext_vector(
34+
; CHECK-CI-NEXT: [[T1:%.*]] = zext <2 x i1> [[T0:%.*]] to <2 x i32>
35+
; CHECK-CI-NEXT: ret <2 x i1> zeroinitializer
3136
;
3237
%t1 = zext <2 x i1> %t0 to <2 x i32>
3338
%t2 = icmp eq <2 x i32> %t1, <i32 2, i32 2>
@@ -72,10 +77,14 @@ define i1 @sext_icmp(i1 %t0) {
7277
; TODO: SCCP operates poorly with vector ranges
7378

7479
define <2 x i1> @sext_vector(<2 x i1> %t0) {
75-
; CHECK-LABEL: @sext_vector(
76-
; CHECK-NEXT: [[T1:%.*]] = sext <2 x i1> [[T0:%.*]] to <2 x i32>
77-
; CHECK-NEXT: [[T2:%.*]] = icmp eq <2 x i32> [[T1]], splat (i32 2)
78-
; CHECK-NEXT: ret <2 x i1> [[T2]]
80+
; CHECK-CV-LABEL: @sext_vector(
81+
; CHECK-CV-NEXT: [[T1:%.*]] = sext <2 x i1> [[T0:%.*]] to <2 x i32>
82+
; CHECK-CV-NEXT: [[T2:%.*]] = icmp eq <2 x i32> [[T1]], splat (i32 2)
83+
; CHECK-CV-NEXT: ret <2 x i1> [[T2]]
84+
;
85+
; CHECK-CI-LABEL: @sext_vector(
86+
; CHECK-CI-NEXT: [[T1:%.*]] = sext <2 x i1> [[T0:%.*]] to <2 x i32>
87+
; CHECK-CI-NEXT: ret <2 x i1> zeroinitializer
7988
;
8089
%t1 = sext <2 x i1> %t0 to <2 x i32>
8190
%t2 = icmp eq <2 x i32> %t1, <i32 2, i32 2>

0 commit comments

Comments
 (0)