forked from OSchip/llvm-project
[NFC][InstCombine] Negator: tests for extractelement negation
This commit is contained in:
parent
9f19cc8cac
commit
952e7106b3
|
@ -1,6 +1,7 @@
|
|||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt %s -instcombine -S | FileCheck %s
|
||||
|
||||
declare void @use4(i4)
|
||||
declare void @use8(i8)
|
||||
declare void @use_v2i4(<2 x i4>)
|
||||
|
||||
|
@ -914,3 +915,35 @@ define i8 @add_via_or_with_no_common_bits_set_extrause(i8 %x, i8 %y) {
|
|||
%t3 = sub i8 %x, %t2
|
||||
ret i8 %t3
|
||||
}
|
||||
|
||||
; `extractelement` is negatible if source operand is negatible.
|
||||
define i4 @negate_extractelement(<2 x i4> %x, i32 %y, i4 %z) {
|
||||
; CHECK-LABEL: @negate_extractelement(
|
||||
; CHECK-NEXT: [[T0:%.*]] = sub <2 x i4> zeroinitializer, [[X:%.*]]
|
||||
; CHECK-NEXT: call void @use_v2i4(<2 x i4> [[T0]])
|
||||
; CHECK-NEXT: [[T1:%.*]] = extractelement <2 x i4> [[T0]], i32 [[Y:%.*]]
|
||||
; CHECK-NEXT: [[T2:%.*]] = sub i4 [[Z:%.*]], [[T1]]
|
||||
; CHECK-NEXT: ret i4 [[T2]]
|
||||
;
|
||||
%t0 = sub <2 x i4> zeroinitializer, %x
|
||||
call void @use_v2i4(<2 x i4> %t0)
|
||||
%t1 = extractelement <2 x i4> %t0, i32 %y
|
||||
%t2 = sub i4 %z, %t1
|
||||
ret i4 %t2
|
||||
}
|
||||
define i4 @negate_extractelement_extrause(<2 x i4> %x, i32 %y, i4 %z) {
|
||||
; CHECK-LABEL: @negate_extractelement_extrause(
|
||||
; CHECK-NEXT: [[T0:%.*]] = sub <2 x i4> zeroinitializer, [[X:%.*]]
|
||||
; CHECK-NEXT: call void @use_v2i4(<2 x i4> [[T0]])
|
||||
; CHECK-NEXT: [[T1:%.*]] = extractelement <2 x i4> [[T0]], i32 [[Y:%.*]]
|
||||
; CHECK-NEXT: call void @use4(i4 [[T1]])
|
||||
; CHECK-NEXT: [[T2:%.*]] = sub i4 [[Z:%.*]], [[T1]]
|
||||
; CHECK-NEXT: ret i4 [[T2]]
|
||||
;
|
||||
%t0 = sub <2 x i4> zeroinitializer, %x
|
||||
call void @use_v2i4(<2 x i4> %t0)
|
||||
%t1 = extractelement <2 x i4> %t0, i32 %y
|
||||
call void @use4(i4 %t1)
|
||||
%t2 = sub i4 %z, %t1
|
||||
ret i4 %t2
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue