-
Notifications
You must be signed in to change notification settings - Fork 22
Fix CastOp canonicalization #317
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
We currently have a canonicalization pattern for casts that fold multiple casts to a single one:
// Composition.
// %b = cast(%a) : A -> B
// cast(%b) : B -> C
// ===> cast(%a) : A -> C
Looking at the explicit cast section in the specification, it is not generally safe to do so because we may lose information and get a cast whose scemantics are not well-defined.
E.g. consider that we have a value bit<8> x and then the casts (int<16>)(bit<16>) x and (int<16>)(int<8>) x. Both of them will be folded into cast x : b8 -> i16 but the first one does zero extension whereas the second one does sign extension.
We need to adjust the canonicalization pattern to only fold cases that preserve the original meaning.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working