[llvm] r367579 - [InstCombine] add tests with 'ne' predicates; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 1 09:04:12 PDT 2019
Author: spatel
Date: Thu Aug 1 09:04:12 2019
New Revision: 367579
URL: http://llvm.org/viewvc/llvm-project?rev=367579&view=rev
Log:
[InstCombine] add tests with 'ne' predicates; NFC
More coverage for the proposal in D65576.
Modified:
llvm/trunk/test/Transforms/InstCombine/select.ll
Modified: llvm/trunk/test/Transforms/InstCombine/select.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/select.ll?rev=367579&r1=367578&r2=367579&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/select.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/select.ll Thu Aug 1 09:04:12 2019
@@ -1342,6 +1342,36 @@ define i32 @PR23757_swapped(i32 %x) {
ret i32 %sel
}
+define i32 @PR23757_ne(i32 %x, i1* %p) {
+; CHECK-LABEL: @PR23757_ne(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[X:%.*]], 2147483647
+; CHECK-NEXT: store i1 [[CMP]], i1* [[P:%.*]], align 1
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[X]], 1
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 -2147483648, i32 [[ADD]]
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %cmp = icmp ne i32 %x, 2147483647
+ store i1 %cmp, i1* %p ; thwart predicate canonicalization
+ %add = add nsw i32 %x, 1
+ %sel = select i1 %cmp, i32 -2147483648, i32 %add
+ ret i32 %sel
+}
+
+define i32 @PR23757_ne_swapped(i32 %x, i1* %p) {
+; CHECK-LABEL: @PR23757_ne_swapped(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[X:%.*]], 2147483647
+; CHECK-NEXT: store i1 [[CMP]], i1* [[P:%.*]], align 1
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[X]], 1
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 [[ADD]], i32 -2147483648
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %cmp = icmp ne i32 %x, 2147483647
+ store i1 %cmp, i1* %p ; thwart predicate canonicalization
+ %add = add nsw i32 %x, 1
+ %sel = select i1 %cmp, i32 %add, i32 -2147483648
+ ret i32 %sel
+}
+
; max(max(~a, -1), -1) --> ~min(a, 0)
define i32 @PR27137(i32 %a) {
More information about the llvm-commits
mailing list