[llvm] r291043 - [InstSimplify] add tests to show missing select simplifications; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 4 16:40:53 PST 2017
Author: spatel
Date: Wed Jan 4 18:40:52 2017
New Revision: 291043
URL: http://llvm.org/viewvc/llvm-project?rev=291043&view=rev
Log:
[InstSimplify] add tests to show missing select simplifications; NFC
Modified:
llvm/trunk/test/Transforms/InstSimplify/select.ll
Modified: llvm/trunk/test/Transforms/InstSimplify/select.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/select.ll?rev=291043&r1=291042&r2=291043&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/select.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/select.ll Wed Jan 4 18:40:52 2017
@@ -402,3 +402,31 @@ define i32* @select_icmp_pointers(i32* %
ret i32* %sel
}
+; FIXME: If the condition is known, we don't need to select.
+
+declare void @llvm.assume(i1)
+
+define i8 @assume_sel_cond(i1 %cond, i8 %x, i8 %y) {
+; CHECK-LABEL: @assume_sel_cond(
+; CHECK-NEXT: call void @llvm.assume(i1 %cond)
+; CHECK-NEXT: [[SEL:%.*]] = select i1 %cond, i8 %x, i8 %y
+; CHECK-NEXT: ret i8 [[SEL]]
+;
+ call void @llvm.assume(i1 %cond)
+ %sel = select i1 %cond, i8 %x, i8 %y
+ ret i8 %sel
+}
+
+define i8 @do_not_assume_sel_cond(i1 %cond, i8 %x, i8 %y) {
+; CHECK-LABEL: @do_not_assume_sel_cond(
+; CHECK-NEXT: [[NOTCOND:%.*]] = icmp eq i1 %cond, false
+; CHECK-NEXT: call void @llvm.assume(i1 [[NOTCOND]])
+; CHECK-NEXT: [[SEL:%.*]] = select i1 %cond, i8 %x, i8 %y
+; CHECK-NEXT: ret i8 [[SEL]]
+;
+ %notcond = icmp eq i1 %cond, false
+ call void @llvm.assume(i1 %notcond)
+ %sel = select i1 %cond, i8 %x, i8 %y
+ ret i8 %sel
+}
+
More information about the llvm-commits
mailing list