[llvm] [InstCombine] Convert fshl(x, 0, y) to shl(x, and(y, BitWidth - 1)) when BitWidth is pow2 (PR #122362)
Amr Hesham via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 11 00:18:12 PST 2025
================
@@ -1010,3 +1010,50 @@ define <2 x i32> @fshr_vec_zero_elem(<2 x i32> %x, <2 x i32> %y) {
%fsh = call <2 x i32> @llvm.fshr.v2i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> <i32 2, i32 0>)
ret <2 x i32> %fsh
}
+
+define i16 @fshl_i16_shl(i16 %x, i16 %y) {
+; CHECK-LABEL: @fshl_i16_shl(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TMP0:%.*]] = and i16 [[Y:%.*]], 15
+; CHECK-NEXT: [[RES:%.*]] = shl i16 [[X:%.*]], [[TMP0]]
+; CHECK-NEXT: ret i16 [[RES]]
+;
+entry:
+ %res = call i16 @llvm.fshl.i16(i16 %x, i16 0, i16 %y)
+ ret i16 %res
+}
+
+define i32 @fshl_i32_shl(i32 %x, i32 %y) {
+; CHECK-LABEL: @fshl_i32_shl(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TMP0:%.*]] = and i32 [[Y:%.*]], 31
+; CHECK-NEXT: [[RES:%.*]] = shl i32 [[X:%.*]], [[TMP0]]
+; CHECK-NEXT: ret i32 [[RES]]
+;
+entry:
+ %res = call i32 @llvm.fshl.i32(i32 %x, i32 0, i32 %y)
+ ret i32 %res
+}
+
+define <2 x i16> @fshl_vi16_shl(<2 x i16> %x, <2 x i16> %y) {
----------------
AmrDeveloper wrote:
All comments addressed, Thank you
https://github.com/llvm/llvm-project/pull/122362
More information about the llvm-commits
mailing list