
Change all the cstval_pred_ty based PatternMatch helpers (things like m_AllOnes and m_Zero) to only allow poison elements inside vector splats, not undef elements. Historically, we used to represent non-demanded elements in vectors using undef. Nowadays, we use poison instead. As such, I believe that support for undef in vector splats is no longer useful. At the same time, while poison splat elements are pretty much always safe to ignore, this is not generally the case for undef elements. We have existing miscompiles in our tests due to this (see the masked-merge-*.ll tests changed here) and it's easy to miss such cases in the future, now that we write tests using poison instead of undef elements. I think overall, keeping support for undef elements no longer makes sense, and we should drop it. Once this is done consistently, I think we may also consider allowing poison in m_APInt by default, as doing that change is much less risky than doing the same with undef. This change involves a substantial amount of test changes. For most tests, I've just replaced undef with poison, as I don't think there is value in retaining both. For some tests (where the distinction between undef and poison is important), I've duplicated tests.
69 lines
1.4 KiB
LLVM
69 lines
1.4 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
|
|
|
|
define i32 @sub_self(i32 %A) {
|
|
; CHECK-LABEL: @sub_self(
|
|
; CHECK-NEXT: ret i32 0
|
|
;
|
|
%B = sub i32 %A, %A
|
|
ret i32 %B
|
|
}
|
|
|
|
define <2 x i32> @sub_self_vec(<2 x i32> %A) {
|
|
; CHECK-LABEL: @sub_self_vec(
|
|
; CHECK-NEXT: ret <2 x i32> zeroinitializer
|
|
;
|
|
%B = sub <2 x i32> %A, %A
|
|
ret <2 x i32> %B
|
|
}
|
|
|
|
define i32 @sub_zero(i32 %A) {
|
|
; CHECK-LABEL: @sub_zero(
|
|
; CHECK-NEXT: ret i32 [[A:%.*]]
|
|
;
|
|
%B = sub i32 %A, 0
|
|
ret i32 %B
|
|
}
|
|
|
|
define <2 x i32> @sub_zero_vec(<2 x i32> %A) {
|
|
; CHECK-LABEL: @sub_zero_vec(
|
|
; CHECK-NEXT: ret <2 x i32> [[A:%.*]]
|
|
;
|
|
%B = sub <2 x i32> %A, <i32 0, i32 poison>
|
|
ret <2 x i32> %B
|
|
}
|
|
|
|
define i32 @neg_neg(i32 %A) {
|
|
; CHECK-LABEL: @neg_neg(
|
|
; CHECK-NEXT: ret i32 [[A:%.*]]
|
|
;
|
|
%B = sub i32 0, %A
|
|
%C = sub i32 0, %B
|
|
ret i32 %C
|
|
}
|
|
|
|
define <2 x i32> @neg_neg_vec(<2 x i32> %A) {
|
|
; CHECK-LABEL: @neg_neg_vec(
|
|
; CHECK-NEXT: ret <2 x i32> [[A:%.*]]
|
|
;
|
|
%B = sub <2 x i32> <i32 0, i32 poison>, %A
|
|
%C = sub <2 x i32> <i32 0, i32 poison>, %B
|
|
ret <2 x i32> %C
|
|
}
|
|
|
|
define i32 @poison1(i32 %x) {
|
|
; CHECK-LABEL: @poison1(
|
|
; CHECK-NEXT: ret i32 poison
|
|
;
|
|
%v = sub i32 %x, poison
|
|
ret i32 %v
|
|
}
|
|
|
|
define i32 @poison2(i32 %x) {
|
|
; CHECK-LABEL: @poison2(
|
|
; CHECK-NEXT: ret i32 poison
|
|
;
|
|
%v = sub i32 poison, %x
|
|
ret i32 %v
|
|
}
|