[llvm] [InstCombine] When -A + B both have nsw flag, set nsw flag. (PR #72127)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 13 08:01:48 PST 2023
================
@@ -120,6 +120,36 @@ define i32 @test5(i32 %A, i32 %B) {
ret i32 %D
}
+define i32 @test5_2(i32 %A, i32 %B) {
+; CHECK-LABEL: @test5_2(
+; CHECK-NEXT: [[D:%.*]] = sub nsw i32 [[B:%.*]], [[A:%.*]]
+; CHECK-NEXT: ret i32 [[D]]
+;
+ %C = sub nsw i32 0, %A
+ %D = add nsw i32 %C, %B
+ ret i32 %D
+}
+
+define i32 @test5_3(i32 %A, i32 %B) {
----------------
nikic wrote:
```suggestion
define i32 @test5_neg_nsw(i32 %A, i32 %B) {
```
https://github.com/llvm/llvm-project/pull/72127
More information about the llvm-commits
mailing list