Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 4239e23

Browse files
committed
[InstCombine] allow vector constants for cast+icmp fold
This is step 1 of unknown towards fixing PR28001: https://llvm.org/bugs/show_bug.cgi?id=28001 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271810 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent b6dac61 commit 4239e23

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2439,7 +2439,7 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
24392439
}
24402440

24412441
// If we aren't dealing with a constant on the RHS, exit early.
2442-
auto *CI = dyn_cast<ConstantInt>(ICI.getOperand(1));
2442+
auto *CI = dyn_cast<Constant>(ICI.getOperand(1));
24432443
if (!CI)
24442444
return nullptr;
24452445

test/Transforms/InstCombine/cast.ll

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,19 +214,26 @@ define i1 @test19(i32 %X) {
214214
ret i1 %Z
215215
}
216216

217-
; FIXME: Vector should be the same as scalar.
218-
219217
define <2 x i1> @test19vec(<2 x i32> %X) {
220218
; CHECK-LABEL: @test19vec(
221-
; CHECK-NEXT: [[C:%.*]] = sext <2 x i32> %X to <2 x i64>
222-
; CHECK-NEXT: [[Z:%.*]] = icmp slt <2 x i64> [[C]], <i64 12345, i64 2147483647>
219+
; CHECK-NEXT: [[Z:%.*]] = icmp slt <2 x i32> %X, <i32 12345, i32 2147483647>
223220
; CHECK-NEXT: ret <2 x i1> [[Z]]
224221
;
225222
%c = sext <2 x i32> %X to <2 x i64>
226223
%Z = icmp slt <2 x i64> %c, <i64 12345, i64 2147483647>
227224
ret <2 x i1> %Z
228225
}
229226

227+
define <3 x i1> @test19vec2(<3 x i1> %X) {
228+
; CHECK-LABEL: @test19vec2(
229+
; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq <3 x i1> %X, zeroinitializer
230+
; CHECK-NEXT: ret <3 x i1> [[CMPEQ]]
231+
;
232+
%sext = sext <3 x i1> %X to <3 x i32>
233+
%cmpeq = icmp eq <3 x i32> %sext, zeroinitializer
234+
ret <3 x i1> %cmpeq
235+
}
236+
230237
define i1 @test20(i1 %B) {
231238
; CHECK-LABEL: @test20(
232239
; CHECK-NEXT: ret i1 false

test/Transforms/InstCombine/signed-comparison.ll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@ define i1 @scalar_zext_slt(i16 %t4) {
1313
ret i1 %t6
1414
}
1515

16-
; FIXME: Vector compare should work the same as scalar.
17-
1816
define <4 x i1> @vector_zext_slt(<4 x i16> %t4) {
1917
; CHECK-LABEL: @vector_zext_slt(
20-
; CHECK-NEXT: [[T5:%.*]] = zext <4 x i16> %t4 to <4 x i32>
21-
; CHECK-NEXT: [[T6:%.*]] = icmp ult <4 x i32> [[T5]], <i32 500, i32 0, i32 501, i32 65535>
18+
; CHECK-NEXT: [[T6:%.*]] = icmp ult <4 x i16> %t4, <i16 500, i16 0, i16 501, i16 -1>
2219
; CHECK-NEXT: ret <4 x i1> [[T6]]
2320
;
2421
%t5 = zext <4 x i16> %t4 to <4 x i32>

0 commit comments

Comments
 (0)