Skip to content

Commit 151ddf0

Browse files
[InstCombine] Stop propagating undef when element is demanded
Do not poison `undef` demanded elements in `SimplifyDemandedVectorElts`. A miscompilation issue has been addressed with refined checking. Proofs: https://alive2.llvm.org/ce/z/WA5oD5.
1 parent fc520f8 commit 151ddf0

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
13781378
if (!Elt) return nullptr;
13791379

13801380
Elts.push_back(Elt);
1381-
if (isa<UndefValue>(Elt)) // Already undef or poison.
1381+
if (isa<PoisonValue>(Elt)) // Already poison.
13821382
UndefElts.setBit(i);
13831383
}
13841384

llvm/test/Transforms/InstCombine/insert-const-shuf.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,9 @@ define <3 x float> @twoShufUses(<3 x float> %x) {
9292

9393
; The inserted scalar constant index is out-of-bounds for the shuffle vector constant.
9494

95-
; FIXME: This is a miscompilation
9695
define <5 x i8> @longerMask(<3 x i8> %x) {
9796
; CHECK-LABEL: @longerMask(
98-
; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <3 x i8> [[X:%.*]], <3 x i8> <i8 poison, i8 1, i8 poison>, <5 x i32> <i32 2, i32 1, i32 4, i32 poison, i32 poison>
97+
; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <3 x i8> [[X:%.*]], <3 x i8> <i8 undef, i8 1, i8 poison>, <5 x i32> <i32 2, i32 1, i32 4, i32 3, i32 poison>
9998
; CHECK-NEXT: [[INS:%.*]] = insertelement <5 x i8> [[SHUF]], i8 42, i64 4
10099
; CHECK-NEXT: ret <5 x i8> [[INS]]
101100
;

llvm/test/Transforms/InstCombine/vec_shuffle.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,11 +2333,10 @@ define <2 x float> @uitofp_shuf_narrow(<4 x i32> %x, <4 x i32> %y) {
23332333
ret <2 x float> %r
23342334
}
23352335

2336-
; FIXME: This is a miscompilation
23372336
define <4 x i16> @blend_elements_from_load(ptr align 8 %_0) {
23382337
; CHECK-LABEL: @blend_elements_from_load(
23392338
; CHECK-NEXT: [[LOAD:%.*]] = load <3 x i16>, ptr [[_0:%.*]], align 8
2340-
; CHECK-NEXT: [[RV:%.*]] = shufflevector <3 x i16> <i16 0, i16 poison, i16 poison>, <3 x i16> [[LOAD]], <4 x i32> <i32 0, i32 poison, i32 3, i32 5>
2339+
; CHECK-NEXT: [[RV:%.*]] = shufflevector <3 x i16> <i16 0, i16 undef, i16 poison>, <3 x i16> [[LOAD]], <4 x i32> <i32 0, i32 1, i32 3, i32 5>
23412340
; CHECK-NEXT: ret <4 x i16> [[RV]]
23422341
;
23432342
%load = load <3 x i16>, ptr %_0, align 8

0 commit comments

Comments
 (0)