dmitry-chirkov-dremio commented on code in PR #50372:
URL: https://github.com/apache/arrow/pull/50372#discussion_r3581600411
##########
cpp/src/gandiva/tests/projector_test.cc:
##########
@@ -388,6 +434,226 @@ TEST_F(TestProjector, TestAllIntTypes) {
TestArithmeticOpsForType<arrow::Int64Type, int64_t>(pool_);
}
+TEST_F(TestProjector, TestCommonSubexpressionEliminationIR) {
+ auto field0 = arrow::field("cse_f0", arrow::int32());
+ auto field1 = arrow::field("cse_f1", arrow::int32());
+ auto schema = arrow::schema({field0, field1});
+
+ auto left_sum = TreeExprBuilder::MakeFunction(
+ "add", {TreeExprBuilder::MakeField(field0),
TreeExprBuilder::MakeField(field1)},
+ arrow::int32());
+ auto right_sum = TreeExprBuilder::MakeFunction(
+ "add", {TreeExprBuilder::MakeField(field0),
TreeExprBuilder::MakeField(field1)},
+ arrow::int32());
+ auto square =
+ TreeExprBuilder::MakeFunction("multiply", {left_sum, right_sum},
arrow::int32());
+ auto expr =
+ TreeExprBuilder::MakeExpression(square, arrow::field("cse_out",
arrow::int32()));
+
+ auto configuration = std::make_shared<Configuration>(
Review Comment:
These assertions feel more tied to LLVM's final optimization/lowering
choices than to the CSE pass itself. For example, expecting zero helper calls
and exactly one `add` instruction can change across LLVM versions or target
CPUs even if the folding is still correct.
Would it be safer to keep the structural checks on `DumpUnoptimizedIR()` and
then validate behavior with runtime evaluation assertions, instead of pinning
the optimized IR this tightly?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]