[llvm] 57cb468 - [InstCombine] add test for possible cast-of-select transform; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 14 11:25:24 PST 2020
Author: Sanjay Patel
Date: 2020-01-14T14:23:14-05:00
New Revision: 57cb4685140284907d16673b555fd62307b4cd76
URL: https://github.com/llvm/llvm-project/commit/57cb4685140284907d16673b555fd62307b4cd76
DIFF: https://github.com/llvm/llvm-project/commit/57cb4685140284907d16673b555fd62307b4cd76.diff
LOG: [InstCombine] add test for possible cast-of-select transform; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/trunc.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/trunc.ll b/llvm/test/Transforms/InstCombine/trunc.ll
index 750f62433664..146d0fffa247 100644
--- a/llvm/test/Transforms/InstCombine/trunc.ll
+++ b/llvm/test/Transforms/InstCombine/trunc.ll
@@ -626,3 +626,21 @@ define <2 x i8> @narrow_sub_vec_constant(<2 x i32> %x) {
ret <2 x i8> %tr
}
+; FIXME: If the select is narrowed based on the target's datalayout, we allow more optimizations.
+
+define i16 @PR44545(i32 %t0, i32 %data) {
+; CHECK-LABEL: @PR44545(
+; CHECK-NEXT: [[T1:%.*]] = add nuw nsw i32 [[T0:%.*]], 1
+; CHECK-NEXT: [[ISZERO:%.*]] = icmp eq i32 [[DATA:%.*]], 0
+; CHECK-NEXT: [[FFS:%.*]] = select i1 [[ISZERO]], i32 0, i32 [[T1]]
+; CHECK-NEXT: [[CAST:%.*]] = trunc i32 [[FFS]] to i16
+; CHECK-NEXT: [[SUB:%.*]] = add nsw i16 [[CAST]], -1
+; CHECK-NEXT: ret i16 [[SUB]]
+;
+ %t1 = add nuw nsw i32 %t0, 1
+ %iszero = icmp eq i32 %data, 0
+ %ffs = select i1 %iszero, i32 0, i32 %t1
+ %cast = trunc i32 %ffs to i16
+ %sub = add nsw i16 %cast, -1
+ ret i16 %sub
+}
More information about the llvm-commits
mailing list