RISCV Sign Extension Optimizations CorrelatedValuePropagation

Hello,

I am trying to implement sign extension optimizations for the RISCV target but I am a little confused. For example in the pass
CorrelatedValuePropagation exists a function processSext that converts
all sexts to zexts inside a function. Generally that is cheaper on most targets but not on RISCV because sext is no-op. Can someone help me outline an approach to undo the effect of this pass in the RISCV?

Note that some RISCV passes to address this problem have been already been created by Craig Topper.

I have read already from a presentation of Craig Topper SignExtensionsOptimizations
that we can add something like nsw/nuw/exact to have a way to retain the information of this conversion. But I don’t know where to insert it exactly. Maybe in CastInst ? because that’s the one that converts a sext to a zext or a bitcast.