diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2020-01-14 13:51:22 -0500 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2020-01-14 14:23:14 -0500 |
| commit | 57cb4685140284907d16673b555fd62307b4cd76 (patch) | |
| tree | 77116e0fe8634a98b1f3363650f661a51110192e /llvm/test/Transforms | |
| parent | b777e551f044bbc7245a0b535e46000469479ff6 (diff) | |
| download | bcm5719-llvm-57cb4685140284907d16673b555fd62307b4cd76.tar.gz bcm5719-llvm-57cb4685140284907d16673b555fd62307b4cd76.zip | |
[InstCombine] add test for possible cast-of-select transform; NFC
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/trunc.ll | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/trunc.ll b/llvm/test/Transforms/InstCombine/trunc.ll index 750f6243366..146d0fffa24 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 +} |

