Skip to content

Conversation

@tlively
Copy link
Member

@tlively tlively commented Jul 19, 2024

Generalize the code for simplifying element segments to handle more than
just null and funcref elements.

@tlively tlively requested a review from kripken July 19, 2024 23:10
}
// Replace the element if it is different from our first "zero"
// element.
return !ExpressionAnalyzer::equal(first, elem);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks flipped? Before we returned f->func == e->func which meant we return true when they were equal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

Base automatically changed from threads-subtype-depths to main July 23, 2024 20:03
tlively added 2 commits July 23, 2024 13:07
Generalize the code for simplifying element segments to handle more than
just null and funcref elements.
@tlively tlively force-pushed the fix-reduce-segment-cast branch from 2c055b3 to 2969e98 Compare July 23, 2024 20:09
(table 481 481 funcref)
(table 354 354 i31ref)
(elem (i32.const 0) $f0 $f0 $f1 $f2 $f0 $f3 $f0)
(elem (table 1) (i32.const 0) i31ref (item (ref.i31 (i32.const 0))) (item (ref.i31 (i32.const 1))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you make one of these values different than 0 and 1 then I think it will not be removed, which would show that we keep things that are needed.

Suggested change
(elem (table 1) (i32.const 0) i31ref (item (ref.i31 (i32.const 0))) (item (ref.i31 (i32.const 1))))
(elem (table 1) (i32.const 0) i31ref (item (ref.i31 (i32.const 0))) (item (ref.i31 (i32.const 42))))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks!

(func $f5 (result i32)
(i32.add
(i31.get_s (table.get 1 (i32.const 0)))
(i31.get_u (table.get 1 (i32.const 1)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the suggestion above I think one of these two operations will get reduced but not the other.

(table 481 481 funcref)
(table 354 354 i31ref)
(elem (i32.const 0) $f0 $f0 $f1 $f2 $f0 $f3 $f0)
(elem (table 1) (i32.const 0) i31ref (item (ref.i31 (i32.const 0))) (item (ref.i31 (i32.const 42))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, now it isn't removing anything here... maybe add a final item with some value (doesn't matter what)?

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the iteration here, but now I think this fully tests the change, nice!

@tlively tlively enabled auto-merge (squash) July 23, 2024 23:13
@tlively tlively disabled auto-merge July 26, 2024 19:50
@tlively tlively merged commit f938154 into main Jul 26, 2024
@tlively tlively deleted the fix-reduce-segment-cast branch July 26, 2024 19:50
@gkdn gkdn mentioned this pull request Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants