This matches when SelectionDAG does.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I don't understand why that would be true for SHL but not for the other shifts. What are the rules for undef in MIR? Is it like undef in IR, or like poison in IR, or neither?
llvm/include/llvm/Target/GlobalISel/Combine.td | ||
---|---|---|
238 | I like 'rhs' but all the existing combine names seem to use 'left' and 'right'. |
I'm not exactly sure of the reasoning, it's just what the IR optimizations and SelectionDAG do. SelectionDAG optimizes the other shifts of undef to undef too.
Actually G_SHL with undef LHS needs to be optimized to zero, not undef.
At the IR level, InstSimplify does this for all shifts (in the absence of exact/nsw/nuw flags). See SimplifyRightShift and SimplifyShlInst.
LGTM. (As I understand it the rationale is that if the rhs is undef, you can assume it is a value >= the bitwidth, so the result is undef.)
I like 'rhs' but all the existing combine names seem to use 'left' and 'right'.