diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2021-03-21 13:45:23 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-03-21 15:30:30 +0100 |
commit | ece1403acadadf0b101bc68a8c69c613ca4f816f (patch) | |
tree | 402bbd4e092f1324b38a6973caa99c626369a2f3 | |
parent | daae927f9c130000c914a27dd1392599190d470f (diff) | |
download | llvm-ece1403acadadf0b101bc68a8c69c613ca4f816f.zip llvm-ece1403acadadf0b101bc68a8c69c613ca4f816f.tar.gz llvm-ece1403acadadf0b101bc68a8c69c613ca4f816f.tar.bz2 |
[InstSimplify] Add additional select operand replacement tests (NFC)
This tests for binops with identity elements.
-rw-r--r-- | llvm/test/Transforms/InstSimplify/select.ll | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/select.ll b/llvm/test/Transforms/InstSimplify/select.ll index 6460b42..86d7672 100644 --- a/llvm/test/Transforms/InstSimplify/select.ll +++ b/llvm/test/Transforms/InstSimplify/select.ll @@ -969,6 +969,52 @@ define <vscale x 2 x i1> @ignore_scalable_undef(<vscale x 2 x i1> %cond) { ret <vscale x 2 x i1> %s } +define i32 @select_neutral_add_rhs(i32 %x, i32 %y) { +; CHECK-LABEL: @select_neutral_add_rhs( +; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret i32 [[ADD]] +; + %cmp = icmp ne i32 %y, 0 + %add = add i32 %x, %y + %sel = select i1 %cmp, i32 %add, i32 %x + ret i32 %sel +} + +define i32 @select_neutral_add_lhs(i32 %x, i32 %y) { +; CHECK-LABEL: @select_neutral_add_lhs( +; CHECK-NEXT: [[ADD:%.*]] = add i32 [[Y:%.*]], [[X:%.*]] +; CHECK-NEXT: ret i32 [[ADD]] +; + %cmp = icmp ne i32 %y, 0 + %add = add i32 %y, %x + %sel = select i1 %cmp, i32 %add, i32 %x + ret i32 %sel +} + +define i32 @select_neutral_sub_rhs(i32 %x, i32 %y) { +; CHECK-LABEL: @select_neutral_sub_rhs( +; CHECK-NEXT: [[ADD:%.*]] = sub i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: ret i32 [[ADD]] +; + %cmp = icmp ne i32 %y, 0 + %add = sub i32 %x, %y + %sel = select i1 %cmp, i32 %add, i32 %x + ret i32 %sel +} + +define i32 @select_neutral_sub_lhs(i32 %x, i32 %y) { +; CHECK-LABEL: @select_neutral_sub_lhs( +; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[Y:%.*]], 0 +; CHECK-NEXT: [[ADD:%.*]] = sub i32 [[Y]], [[X:%.*]] +; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 [[ADD]], i32 [[X]] +; CHECK-NEXT: ret i32 [[SEL]] +; + %cmp = icmp ne i32 %y, 0 + %add = sub i32 %y, %x + %sel = select i1 %cmp, i32 %add, i32 %x + ret i32 %sel +} + ; TODO: these can be optimized more define i32 @poison(i32 %x, i32 %y) { |