Skip to content

Commit 6d6287a

Browse files
authored
[NFC] Fix test for zext(shl(trunc)) fold (#113778)
This fold already exist but there is a call to [shouldChangeType ](https://github.com/llvm/llvm-project/blob/91fdfec263ff2b8e88433c4294a550cabb0f2314/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp#L1202) that blocks it if the target layout is missing a definition of the types in the casts. closes #61650
1 parent 117e952 commit 6d6287a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/test/Transforms/InstCombine/trunc-shl-zext.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
22
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
33

4+
target datalayout = "n8:16:32:64"
5+
46
define i32 @trunc_shl_zext_32(i32 %a) {
57
; CHECK-LABEL: define i32 @trunc_shl_zext_32
68
; CHECK-SAME: (i32 [[A:%.*]]) {
7-
; CHECK-NEXT: [[TRUNC:%.*]] = trunc i32 [[A]] to i16
8-
; CHECK-NEXT: [[SHL:%.*]] = shl i16 [[TRUNC]], 4
9-
; CHECK-NEXT: [[EXT:%.*]] = zext i16 [[SHL]] to i32
9+
; CHECK-NEXT: [[SHL:%.*]] = shl i32 [[A]], 4
10+
; CHECK-NEXT: [[EXT:%.*]] = and i32 [[SHL]], 65520
1011
; CHECK-NEXT: ret i32 [[EXT]]
1112
;
1213
%trunc = trunc i32 %a to i16
@@ -18,9 +19,8 @@ define i32 @trunc_shl_zext_32(i32 %a) {
1819
define i64 @trunc_shl_zext_64(i64 %a) {
1920
; CHECK-LABEL: define i64 @trunc_shl_zext_64
2021
; CHECK-SAME: (i64 [[A:%.*]]) {
21-
; CHECK-NEXT: [[TRUNC:%.*]] = trunc i64 [[A]] to i8
22-
; CHECK-NEXT: [[SHL:%.*]] = shl i8 [[TRUNC]], 7
23-
; CHECK-NEXT: [[EXT:%.*]] = zext i8 [[SHL]] to i64
22+
; CHECK-NEXT: [[SHL:%.*]] = shl i64 [[A]], 7
23+
; CHECK-NEXT: [[EXT:%.*]] = and i64 [[SHL]], 128
2424
; CHECK-NEXT: ret i64 [[EXT]]
2525
;
2626
%trunc = trunc i64 %a to i8

0 commit comments

Comments
 (0)