Skip to content

Commit 445c43d

Browse files
committed
[InstCombine] Add test for missing (or (zext x), (shl (ashr x, bw-1))) -> (sext x) case
#129363 handled all the cases where there was a sext for the original source value, but not for cases where the source is already half the size of the destination type Another regression noticed in #76524
1 parent afbbca5 commit 445c43d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

llvm/test/Transforms/InstCombine/iX-ext-split.ll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,31 @@ entry:
8989
ret void
9090
}
9191

92+
; (non)ext split from i64 to i128
93+
define void @i128_ext_split_store_i64(i64 %x, ptr %out) {
94+
; CHECK-LABEL: define void @i128_ext_split_store_i64(
95+
; CHECK-SAME: i64 [[X:%.*]], ptr [[OUT:%.*]]) {
96+
; CHECK-NEXT: [[ENTRY:.*:]]
97+
; CHECK-NEXT: [[LO:%.*]] = zext i64 [[X]] to i128
98+
; CHECK-NEXT: [[SIGN:%.*]] = ashr i64 [[X]], 63
99+
; CHECK-NEXT: [[WIDEN:%.*]] = zext i64 [[SIGN]] to i128
100+
; CHECK-NEXT: [[HI:%.*]] = shl nuw i128 [[WIDEN]], 64
101+
; CHECK-NEXT: [[RES:%.*]] = or disjoint i128 [[HI]], [[LO]]
102+
; CHECK-NEXT: store i128 [[RES]], ptr [[OUT]], align 16
103+
; CHECK-NEXT: ret void
104+
;
105+
entry:
106+
%lo = zext i64 %x to i128
107+
108+
%sign = ashr i64 %x, 63
109+
%widen = zext i64 %sign to i128
110+
%hi = shl nuw i128 %widen, 64
111+
112+
%res = or disjoint i128 %hi, %lo
113+
store i128 %res, ptr %out, align 16
114+
ret void
115+
}
116+
92117
; negative test - wrong constant value
93118
define i128 @i128_ext_split_neg1(i32 %x) {
94119
; CHECK-LABEL: define i128 @i128_ext_split_neg1(

0 commit comments

Comments
 (0)