mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 13:11:39 +01:00
[InstCombine] (~X) - (~Y) --> Y - X
llvm-svn: 326660
This commit is contained in:
parent
728449bd27
commit
9968c706bd
@ -1511,6 +1511,11 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
|
||||
if (match(Op0, m_AllOnes()))
|
||||
return BinaryOperator::CreateNot(Op1);
|
||||
|
||||
// (~X) - (~Y) --> Y - X
|
||||
Value *X, *Y;
|
||||
if (match(Op0, m_Not(m_Value(X))) && match(Op1, m_Not(m_Value(Y))))
|
||||
return BinaryOperator::CreateSub(Y, X);
|
||||
|
||||
if (Constant *C = dyn_cast<Constant>(Op0)) {
|
||||
Value *X;
|
||||
// C - zext(bool) -> bool ? C - 1 : C
|
||||
|
@ -50,7 +50,7 @@ define i8 @notnotsub(i8 %x, i8 %y) {
|
||||
; CHECK-LABEL: @notnotsub(
|
||||
; CHECK-NEXT: [[NX:%.*]] = xor i8 [[X:%.*]], -1
|
||||
; CHECK-NEXT: [[NY:%.*]] = xor i8 [[Y:%.*]], -1
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub i8 [[NX]], [[NY]]
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub i8 [[Y]], [[X]]
|
||||
; CHECK-NEXT: call void @use8(i8 [[NX]])
|
||||
; CHECK-NEXT: call void @use8(i8 [[NY]])
|
||||
; CHECK-NEXT: ret i8 [[SUB]]
|
||||
@ -65,9 +65,7 @@ define i8 @notnotsub(i8 %x, i8 %y) {
|
||||
|
||||
define <2 x i8> @notnotsub_vec(<2 x i8> %x, <2 x i8> %y) {
|
||||
; CHECK-LABEL: @notnotsub_vec(
|
||||
; CHECK-NEXT: [[NX:%.*]] = xor <2 x i8> [[X:%.*]], <i8 -1, i8 -1>
|
||||
; CHECK-NEXT: [[NY:%.*]] = xor <2 x i8> [[Y:%.*]], <i8 -1, i8 -1>
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub <2 x i8> [[NX]], [[NY]]
|
||||
; CHECK-NEXT: [[SUB:%.*]] = sub <2 x i8> [[Y:%.*]], [[X:%.*]]
|
||||
; CHECK-NEXT: ret <2 x i8> [[SUB]]
|
||||
;
|
||||
%nx = xor <2 x i8> %x, <i8 -1, i8 -1>
|
||||
|
Loading…
x
Reference in New Issue
Block a user