diff options
author | Sanjay Patel <spatel@rotateright.com> | 2017-02-18 22:20:09 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2017-02-18 22:20:09 +0000 |
commit | 53c5c3d65df3d48fd147b7786ef56cf9da6548d2 (patch) | |
tree | 0289773ebb088597a27473e757ed1db508c56821 /llvm/test/Transforms/InstCombine/add.ll | |
parent | fe67255961e25c1d88888831d5badb3ec96b4ba2 (diff) | |
download | bcm5719-llvm-53c5c3d65df3d48fd147b7786ef56cf9da6548d2.tar.gz bcm5719-llvm-53c5c3d65df3d48fd147b7786ef56cf9da6548d2.zip |
[InstCombine] add nsw/nuw X, signbit --> or X, signbit
Changing to 'or' (rather than 'xor' when no wrapping flags are set)
allows icmp simplifies to happen as expected.
Differential Revision: https://reviews.llvm.org/D29729
llvm-svn: 295574
Diffstat (limited to 'llvm/test/Transforms/InstCombine/add.ll')
-rw-r--r-- | llvm/test/Transforms/InstCombine/add.ll | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/test/Transforms/InstCombine/add.ll b/llvm/test/Transforms/InstCombine/add.ll index c04953d1a41..73c786dcb26 100644 --- a/llvm/test/Transforms/InstCombine/add.ll +++ b/llvm/test/Transforms/InstCombine/add.ll @@ -267,24 +267,22 @@ define i32 @xor_sign_bit(i32 %x) { ret i32 %add } -; Lose no-wrap info by converting to xor? %x is known non-negative -; here, but not after converting to xor. +; No-wrap info allows converting the add to 'or'. define i8 @add_nsw_signbit(i8 %x) { ; CHECK-LABEL: @add_nsw_signbit( -; CHECK-NEXT: [[Y:%.*]] = xor i8 %x, -128 +; CHECK-NEXT: [[Y:%.*]] = or i8 %x, -128 ; CHECK-NEXT: ret i8 [[Y]] ; %y = add nsw i8 %x, -128 ret i8 %y } -; Lose no-wrap info by converting to xor? %x is known non-negative -; (x < 128 unsigned), but not after converting to xor. +; No-wrap info allows converting the add to 'or'. define i8 @add_nuw_signbit(i8 %x) { ; CHECK-LABEL: @add_nuw_signbit( -; CHECK-NEXT: [[Y:%.*]] = xor i8 %x, -128 +; CHECK-NEXT: [[Y:%.*]] = or i8 %x, -128 ; CHECK-NEXT: ret i8 [[Y]] ; %y = add nuw i8 %x, 128 |