Skip to content

Commit 7631c73

Browse files
authored
[InstCombine] Baseline test exposing vector fp-to-int conversion becoming scalar (llvm#165800)
Baseline test for llvm#165793 exposing the change from a vector fp-to-int conversion into a scalar one inside the loop. Additionally, removed `llvm/test/Transforms/InstCombine/vec_extract_var_elt-inseltpoison.ll`, which was a duplicate of `llvm/test/Transforms/InstCombine/vec_extract_var_elt.ll` differing only by the use of poison in the insert element. The poison variant has been merged into `llvm/test/Transforms/InstCombine/vec_extract_var_elt.ll`. Also improved test naming and updated test checks.
1 parent 60c9066 commit 7631c73

File tree

2 files changed

+64
-35
lines changed

2 files changed

+64
-35
lines changed

llvm/test/Transforms/InstCombine/vec_extract_var_elt-inseltpoison.ll

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,81 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
12
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
23

3-
define void @test (float %b, ptr %p) {
4-
; CHECK: extractelement
5-
; CHECK: fptosi
6-
%1 = load <8 x float> , ptr %p
4+
define void @test_poison(float %b, ptr %p) {
5+
; CHECK-LABEL: define void @test_poison(
6+
; CHECK-SAME: float [[B:%.*]], ptr [[P:%.*]]) {
7+
; CHECK-NEXT: [[TMP1:%.*]] = load <8 x float>, ptr [[P]], align 32
8+
; CHECK-NEXT: [[TMP2:%.*]] = fptosi float [[B]] to i32
9+
; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[TMP2]], -2
10+
; CHECK-NEXT: [[TMP4:%.*]] = extractelement <8 x float> [[TMP1]], i32 [[TMP3]]
11+
; CHECK-NEXT: [[TMP5:%.*]] = fptosi float [[TMP4]] to i32
12+
; CHECK-NEXT: [[TMP6:%.*]] = insertelement <8 x i32> poison, i32 [[TMP5]], i64 7
13+
; CHECK-NEXT: [[TMP7:%.*]] = sitofp <8 x i32> [[TMP6]] to <8 x float>
14+
; CHECK-NEXT: store <8 x float> [[TMP7]], ptr [[P]], align 32
15+
; CHECK-NEXT: ret void
16+
;
17+
%1 = load <8 x float>, ptr %p
718
%2 = bitcast <8 x float> %1 to <8 x i32>
819
%3 = bitcast <8 x i32> %2 to <8 x float>
920
%a = fptosi <8 x float> %3 to <8 x i32>
1021
%4 = fptosi float %b to i32
1122
%5 = add i32 %4, -2
1223
%6 = extractelement <8 x i32> %a, i32 %5
13-
%7 = insertelement <8 x i32> undef, i32 %6, i32 7
24+
%7 = insertelement <8 x i32> poison, i32 %6, i32 7
1425
%8 = sitofp <8 x i32> %7 to <8 x float>
1526
store <8 x float> %8, ptr %p
16-
ret void
27+
ret void
1728
}
1829

1930
; PR18600
20-
define i32 @test2(i32 %i) {
31+
define i32 @test_bitcast(i32 %i) {
32+
; CHECK-LABEL: define i32 @test_bitcast(
33+
; CHECK-SAME: i32 [[I:%.*]]) {
34+
; CHECK-NEXT: [[E:%.*]] = extractelement <4 x i32> <i32 1, i32 0, i32 2, i32 0>, i32 [[I]]
35+
; CHECK-NEXT: ret i32 [[E]]
36+
;
2137
%e = extractelement <4 x i32> bitcast (<2 x i64> <i64 1, i64 2> to <4 x i32>), i32 %i
2238
ret i32 %e
39+
}
40+
41+
declare void @use(i32)
2342

24-
; CHECK-LABEL: @test2
25-
; CHECK: extractelement
43+
define void @test_loop(<4 x float> %in) {
44+
; CHECK-LABEL: define void @test_loop(
45+
; CHECK-SAME: <4 x float> [[IN:%.*]]) {
46+
; CHECK-NEXT: [[ENTRY:.*]]:
47+
; CHECK-NEXT: [[R:%.*]] = call <4 x float> @llvm.x86.sse41.round.ps(<4 x float> [[IN]], i32 9)
48+
; CHECK-NEXT: br label %[[LOOP:.*]]
49+
; CHECK: [[LOOP]]:
50+
; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[NEXT:%.*]], %[[LATCH:.*]] ]
51+
; CHECK-NEXT: [[COND:%.*]] = icmp samesign ult i32 [[I]], 4
52+
; CHECK-NEXT: br i1 [[COND]], label %[[BODY:.*]], label %[[DONE:.*]]
53+
; CHECK: [[BODY]]:
54+
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <4 x float> [[R]], i32 [[I]]
55+
; CHECK-NEXT: [[ELEM:%.*]] = fptosi float [[TMP0]] to i32
56+
; CHECK-NEXT: call void @use(i32 [[ELEM]])
57+
; CHECK-NEXT: br label %[[LATCH]]
58+
; CHECK: [[LATCH]]:
59+
; CHECK-NEXT: [[NEXT]] = add nuw nsw i32 [[I]], 1
60+
; CHECK-NEXT: br label %[[LOOP]]
61+
; CHECK: [[DONE]]:
62+
; CHECK-NEXT: ret void
63+
;
64+
entry:
65+
%r = call <4 x float> @llvm.x86.sse41.round.ps(<4 x float> %in, i32 9)
66+
%vi = fptosi <4 x float> %r to <4 x i32>
67+
br label %loop
68+
loop:
69+
%i = phi i32 [ 0, %entry ], [ %next, %latch ]
70+
%cond = icmp ult i32 %i, 4
71+
br i1 %cond, label %body, label %done
72+
body:
73+
%elem = extractelement <4 x i32> %vi, i32 %i
74+
call void @use(i32 %elem)
75+
br label %latch
76+
latch:
77+
%next = add i32 %i, 1
78+
br label %loop
79+
done:
80+
ret void
2681
}

0 commit comments

Comments
 (0)