diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-03-03 17:20:37 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-03-03 17:20:37 +0000 |
| commit | 73eb2d255529c83e94b2e36d67060a14f60ce1a0 (patch) | |
| tree | cefb427e874f21cd94cfc8a2f2ad6095f22374b3 /llvm | |
| parent | ad403a483a3463efbbbf0cf0119b478a1c2190f5 (diff) | |
| download | bcm5719-llvm-73eb2d255529c83e94b2e36d67060a14f60ce1a0.tar.gz bcm5719-llvm-73eb2d255529c83e94b2e36d67060a14f60ce1a0.zip | |
[InstCombine] add tests for notnotsub; NFC
As shown in D44043, we may need this fold in the backend,
but it's also missing in the IR optimizer.
llvm-svn: 326659
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/sub.ll | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/sub.ll b/llvm/test/Transforms/InstCombine/sub.ll index 88a07a0b200..595748674d0 100644 --- a/llvm/test/Transforms/InstCombine/sub.ll +++ b/llvm/test/Transforms/InstCombine/sub.ll @@ -40,6 +40,42 @@ define i32 @test4(i32 %A, i32 %x) { ret i32 %C } +; FIXME: +; (~X) - (~Y) --> Y - X +; Also, show that we can handle extra uses and vectors. + +declare void @use8(i8) + +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: call void @use8(i8 [[NX]]) +; CHECK-NEXT: call void @use8(i8 [[NY]]) +; CHECK-NEXT: ret i8 [[SUB]] +; + %nx = xor i8 %x, -1 + %ny = xor i8 %y, -1 + %sub = sub i8 %nx, %ny + call void @use8(i8 %nx) + call void @use8(i8 %ny) + ret i8 %sub +} + +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: ret <2 x i8> [[SUB]] +; + %nx = xor <2 x i8> %x, <i8 -1, i8 -1> + %ny = xor <2 x i8> %y, <i8 -1, i8 -1> + %sub = sub <2 x i8> %nx, %ny + ret <2 x i8> %sub +} + define i32 @test5(i32 %A, i32 %B, i32 %C) { ; CHECK-LABEL: @test5( ; CHECK-NEXT: [[D1:%.*]] = sub i32 [[C:%.*]], [[B:%.*]] |

