Commit 3af514e5 authored by Noah Goldstein's avatar Noah Goldstein
Browse files

[InstCombine] Add tests for improving `sub X, ~Y` -> `add X, -Y`; NFC

parent dfe1d35c
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -22,6 +22,20 @@ define i32 @p0_scalar(i32 %x, i32 %y) {
  ret i32 %t1
}

define i8 @p0_scalar_not_truly_negatable(i8 %x, i8 %y) {
; CHECK-LABEL: @p0_scalar_not_truly_negatable(
; CHECK-NEXT:    [[XX:%.*]] = xor i8 [[X:%.*]], 123
; CHECK-NEXT:    [[TMP1:%.*]] = xor i8 [[Y:%.*]], -46
; CHECK-NEXT:    [[YY_NEG:%.*]] = add i8 [[TMP1]], 1
; CHECK-NEXT:    [[R:%.*]] = add i8 [[YY_NEG]], [[XX]]
; CHECK-NEXT:    ret i8 [[R]]
;
  %xx = xor i8 %x, 123
  %yy = xor i8 %y, 45
  %r = sub i8 %xx, %yy
  ret i8 %r
}

;------------------------------------------------------------------------------;
; Vector tests
;------------------------------------------------------------------------------;