[llvm] fae7d68 - [InstCombine] add tests with nsw/nuw for mul-of-select; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 12 09:57:45 PDT 2021
Author: Sanjay Patel
Date: 2021-10-12T12:57:20-04:00
New Revision: fae7d6886e4ed8d75a8efa6f74562a314d2762aa
URL: https://github.com/llvm/llvm-project/commit/fae7d6886e4ed8d75a8efa6f74562a314d2762aa
DIFF: https://github.com/llvm/llvm-project/commit/fae7d6886e4ed8d75a8efa6f74562a314d2762aa.diff
LOG: [InstCombine] add tests with nsw/nuw for mul-of-select; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/mul-inseltpoison.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/mul-inseltpoison.ll b/llvm/test/Transforms/InstCombine/mul-inseltpoison.ll
index 4b7af9212ae94..5c66ea0721150 100644
--- a/llvm/test/Transforms/InstCombine/mul-inseltpoison.ll
+++ b/llvm/test/Transforms/InstCombine/mul-inseltpoison.ll
@@ -718,6 +718,50 @@ define i32 @negate_if_false(i32 %x, i1 %cond) {
ret i32 %r
}
+define i32 @negate_if_true_nsw(i32 %x, i1 %cond) {
+; CHECK-LABEL: @negate_if_true_nsw(
+; CHECK-NEXT: [[TMP1:%.*]] = sub i32 0, [[X:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[COND:%.*]], i32 [[TMP1]], i32 [[X]]
+; CHECK-NEXT: ret i32 [[TMP2]]
+;
+ %sel = select i1 %cond, i32 -1, i32 1
+ %r = mul nsw i32 %sel, %x
+ ret i32 %r
+}
+
+define i32 @negate_if_true_nuw(i32 %x, i1 %cond) {
+; CHECK-LABEL: @negate_if_true_nuw(
+; CHECK-NEXT: [[TMP1:%.*]] = sub i32 0, [[X:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[COND:%.*]], i32 [[TMP1]], i32 [[X]]
+; CHECK-NEXT: ret i32 [[TMP2]]
+;
+ %sel = select i1 %cond, i32 -1, i32 1
+ %r = mul nuw i32 %sel, %x
+ ret i32 %r
+}
+
+define i32 @negate_if_false_nsw(i32 %x, i1 %cond) {
+; CHECK-LABEL: @negate_if_false_nsw(
+; CHECK-NEXT: [[TMP1:%.*]] = sub i32 0, [[X:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[COND:%.*]], i32 [[X]], i32 [[TMP1]]
+; CHECK-NEXT: ret i32 [[TMP2]]
+;
+ %sel = select i1 %cond, i32 1, i32 -1
+ %r = mul nsw i32 %sel, %x
+ ret i32 %r
+}
+
+define i32 @negate_if_false_nuw(i32 %x, i1 %cond) {
+; CHECK-LABEL: @negate_if_false_nuw(
+; CHECK-NEXT: [[TMP1:%.*]] = sub i32 0, [[X:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[COND:%.*]], i32 [[X]], i32 [[TMP1]]
+; CHECK-NEXT: ret i32 [[TMP2]]
+;
+ %sel = select i1 %cond, i32 1, i32 -1
+ %r = mul nuw i32 %sel, %x
+ ret i32 %r
+}
+
define <2 x i8> @negate_if_true_commute(<2 x i8> %px, i1 %cond) {
; CHECK-LABEL: @negate_if_true_commute(
; CHECK-NEXT: [[X:%.*]] = sdiv <2 x i8> <i8 42, i8 42>, [[PX:%.*]]
More information about the llvm-commits
mailing list