[AArch64][PeepholeOpt]Optimize ALU + compare to flag-setting ALU
The motivating example is in https://godbolt.org/z/45nbdYMK9 - For this example, `subs` is generated for the good case; `sub` followed by `cmp` is generated for the bad case. Since signed overflow is undefined behavior in C/C++ (indicated as `nsw` flag in LLVM IR), `subs` should be generated for the good case as well. This patch relaxes one restriction from "quit optimization when V is used" to "continue if MI produces poison value when signed overflow occurs". This is not meant to be C/C++ specific since it looks at 'NoSWrap' since it looks at MachineInstr flags. Reviewed By: dmgreen Differential Revision: https://reviews.llvm.org/D146820
Loading
Please sign in to comment