On Sat, Jan 2, 2021 at 2:09 AM Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> wrote: > > It's easy enough to add a test to only allow this on 'true' integer types > like done in the patch. We already linearize casts to different ops for the different cases (integer/pointer/fp/bool). So yeah, we should do it at that level. > Again it's easy enough to add some checks but I wonder if all this > is really worth. I agree. Remove it from the evaluation phase, and add it to the linearized SSA format instead. Note that even on RISC architectures that don't even _have_ truncated operations (ie an "add" or "not" is always done on the whole register), doing the truncation to minimal bits is worth it, because it ends up being just a "upper bits don't matter" and will remove a _lot_ of sign-extension or zero-extension crud. So I think the simplification should be done, but I agree it's done in the wrong place. Once you do it at the instruction simplification level, all of the confusion goes away, because a "cast to floating point" is a fundamentally different operation than "zero-extend integer" at that level. Linus