[llvm] [InstCombine] Fold shuffles through all trivially vectorizable intrinsics (PR #141979)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri May 30 04:08:27 PDT 2025


================
@@ -978,3 +978,14 @@ define i32 @abs_diff_signed_slt_no_nsw_swap(i32 %a, i32 %b) {
   %cond = select i1 %cmp, i32 %sub_ba, i32 %sub_ab
   ret i32 %cond
 }
+
+define <2 x i32> @abs_unary_shuffle_ops(<2 x i32> %x) {
+; CHECK-LABEL: @abs_unary_shuffle_ops(
+; CHECK-NEXT:    [[R2:%.*]] = call <2 x i32> @llvm.abs.v2i32(<2 x i32> [[R1:%.*]], i1 false)
+; CHECK-NEXT:    [[R:%.*]] = shufflevector <2 x i32> [[R2]], <2 x i32> poison, <2 x i32> <i32 1, i32 0>
+; CHECK-NEXT:    ret <2 x i32> [[R]]
+;
+  %a = shufflevector <2 x i32> %x, <2 x i32> poison, <2 x i32> <i32 1, i32 0>
----------------
nikic wrote:

For example, what happens if you add an extra use to this shufflevector? I think it will fold thanks to the i1 false argument.

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


More information about the llvm-commits mailing list