[llvm] [InstCombine] Fold adds + shifts with nsw and nuw flags (PR #88193)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed May 1 07:08:45 PDT 2024


================
@@ -360,8 +360,33 @@ define <3 x i14> @mul_splat_fold_vec(<3 x i14> %x) {
   ret <3 x i14> %t
 }
 
+define i32 @shl_add_lshr(i32 %x, i32 %c, i32 %y) {
----------------
dtcxzyw wrote:

Please rename this test to `shl_add_lshr_flag_preservation`, and add the following basic test:
```
define i32 @shl_add_lshr(i32 %x, i32 %c, i32 %y) {
   %shl = shl nuw i32 %x, %c
   %add = add nuw i32 %shl, %y
   %lshr = lshr i32 %add, %c
   ret i32 %lshr
}
```

https://github.com/llvm/llvm-project/pull/88193


More information about the llvm-commits mailing list