@@ -29,7 +29,7 @@ struct LegalityTest : public testing::Test {
29
29
30
30
TEST_F (LegalityTest, Legality) {
31
31
parseIR (C, R"IR(
32
- define void @foo(ptr %ptr, <2 x float> %vec2, <3 x float> %vec3, i8 %arg) {
32
+ define void @foo(ptr %ptr, <2 x float> %vec2, <3 x float> %vec3, i8 %arg, float %farg0, float %farg1 ) {
33
33
%gep0 = getelementptr float, ptr %ptr, i32 0
34
34
%gep1 = getelementptr float, ptr %ptr, i32 1
35
35
%gep3 = getelementptr float, ptr %ptr, i32 3
@@ -40,6 +40,8 @@ define void @foo(ptr %ptr, <2 x float> %vec2, <3 x float> %vec3, i8 %arg) {
40
40
store <2 x float> %vec2, ptr %gep1
41
41
store <3 x float> %vec3, ptr %gep3
42
42
store i8 %arg, ptr %gep1
43
+ %fadd0 = fadd float %farg0, %farg0
44
+ %fadd1 = fadd fast float %farg1, %farg1
43
45
ret void
44
46
}
45
47
)IR" );
@@ -58,6 +60,8 @@ define void @foo(ptr %ptr, <2 x float> %vec2, <3 x float> %vec3, i8 %arg) {
58
60
auto *StVec2 = cast<sandboxir::StoreInst>(&*It++);
59
61
auto *StVec3 = cast<sandboxir::StoreInst>(&*It++);
60
62
auto *StI8 = cast<sandboxir::StoreInst>(&*It++);
63
+ auto *FAdd0 = cast<sandboxir::BinaryOperator>(&*It++);
64
+ auto *FAdd1 = cast<sandboxir::BinaryOperator>(&*It++);
61
65
62
66
sandboxir::LegalityAnalysis Legality;
63
67
const auto &Result = Legality.canVectorize ({St0, St1});
@@ -87,6 +91,13 @@ define void @foo(ptr %ptr, <2 x float> %vec2, <3 x float> %vec3, i8 %arg) {
87
91
EXPECT_EQ (cast<sandboxir::Pack>(Result).getReason (),
88
92
sandboxir::ResultReason::DiffTypes);
89
93
}
94
+ {
95
+ // Check DiffMathFlags
96
+ const auto &Result = Legality.canVectorize ({FAdd0, FAdd1});
97
+ EXPECT_TRUE (isa<sandboxir::Pack>(Result));
98
+ EXPECT_EQ (cast<sandboxir::Pack>(Result).getReason (),
99
+ sandboxir::ResultReason::DiffMathFlags);
100
+ }
90
101
}
91
102
92
103
#ifndef NDEBUG
@@ -110,5 +121,8 @@ TEST_F(LegalityTest, LegalityResultDump) {
110
121
EXPECT_TRUE (Matches (Legality.createLegalityResult <sandboxir::Pack>(
111
122
sandboxir::ResultReason::DiffTypes),
112
123
" Pack Reason: DiffTypes" ));
124
+ EXPECT_TRUE (Matches (Legality.createLegalityResult <sandboxir::Pack>(
125
+ sandboxir::ResultReason::DiffMathFlags),
126
+ " Pack Reason: DiffMathFlags" ));
113
127
}
114
128
#endif // NDEBUG
0 commit comments