[llvm] 60429fb - [InstCombine] Add more tests for select equivalence fold (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 6 00:38:17 PDT 2024
Author: Nikita Popov
Date: 2024-06-06T09:38:08+02:00
New Revision: 60429fbf88607dc3081e9faafb767bfbe996cfaa
URL: https://github.com/llvm/llvm-project/commit/60429fbf88607dc3081e9faafb767bfbe996cfaa
DIFF: https://github.com/llvm/llvm-project/commit/60429fbf88607dc3081e9faafb767bfbe996cfaa.diff
LOG: [InstCombine] Add more tests for select equivalence fold (NFC)
Added:
Modified:
llvm/test/Transforms/InstCombine/select.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/select.ll b/llvm/test/Transforms/InstCombine/select.ll
index d3cf2af4be652..d110cc9f9eb4e 100644
--- a/llvm/test/Transforms/InstCombine/select.ll
+++ b/llvm/test/Transforms/InstCombine/select.ll
@@ -2797,6 +2797,19 @@ define <2 x i8> @select_replacement_add_eq_vec_poison(<2 x i8> %x, <2 x i8> %y)
ret <2 x i8> %sel
}
+define <2 x i8> @select_replacement_add_eq_vec_undef(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: @select_replacement_add_eq_vec_undef(
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i8> [[X:%.*]], <i8 1, i8 undef>
+; CHECK-NEXT: [[ADD:%.*]] = add <2 x i8> [[X]], <i8 1, i8 1>
+; CHECK-NEXT: [[SEL:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[ADD]], <2 x i8> [[Y:%.*]]
+; CHECK-NEXT: ret <2 x i8> [[SEL]]
+;
+ %cmp = icmp eq <2 x i8> %x, <i8 1, i8 undef>
+ %add = add <2 x i8> %x, <i8 1, i8 1>
+ %sel = select <2 x i1> %cmp, <2 x i8> %add, <2 x i8> %y
+ ret <2 x i8> %sel
+}
+
define i8 @select_replacement_add_ne(i8 %x, i8 %y) {
; CHECK-LABEL: @select_replacement_add_ne(
; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 [[X:%.*]], 1
@@ -2835,6 +2848,21 @@ define i8 @select_replacement_sub_noundef(i8 %x, i8 noundef %y, i8 %z) {
ret i8 %sel
}
+define i8 @select_replacement_sub_noundef_but_may_be_poison(i8 %x, i8 noundef %yy, i8 %z) {
+; CHECK-LABEL: @select_replacement_sub_noundef_but_may_be_poison(
+; CHECK-NEXT: [[Y:%.*]] = shl nuw i8 [[YY:%.*]], 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[Y]], [[X:%.*]]
+; CHECK-NEXT: [[SUB:%.*]] = sub i8 [[X]], [[Y]]
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i8 [[SUB]], i8 [[Z:%.*]]
+; CHECK-NEXT: ret i8 [[SEL]]
+;
+ %y = shl nuw i8 %yy, 1
+ %cmp = icmp eq i8 %x, %y
+ %sub = sub i8 %x, %y
+ %sel = select i1 %cmp, i8 %sub, i8 %z
+ ret i8 %sel
+}
+
; TODO: The transform is also safe without noundef.
define i8 @select_replacement_sub(i8 %x, i8 %y, i8 %z) {
; CHECK-LABEL: @select_replacement_sub(
More information about the llvm-commits
mailing list