[PATCH] D30051: [InstCombine] Do not exercise nested max/min pattern on abs
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 21 06:52:14 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295719: [InstCombine] Do not exercise nested max/min pattern on abs (authored by annat).
Changed prior to commit:
https://reviews.llvm.org/D30051?vs=88767&id=89204#toc
Repository:
rL LLVM
https://reviews.llvm.org/D30051
Files:
llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/trunk/test/Transforms/InstCombine/max-of-nots.ll
Index: llvm/trunk/test/Transforms/InstCombine/max-of-nots.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/max-of-nots.ll
+++ llvm/trunk/test/Transforms/InstCombine/max-of-nots.ll
@@ -90,6 +90,28 @@
ret i32 %smax96
}
+ ; negative test case (i.e. can not simplify) : ABS(MIN(NOT x,y))
+define i32 @abs_of_min_of_not(i32 %x, i32 %y) {
+; CHECK-LABEL: @abs_of_min_of_not(
+; CHECK-NEXT: xor
+; CHECK-NEXT: add
+; CHECK-NEXT: icmp sge
+; CHECK-NEXT: select
+; CHECK-NEXT: icmp sgt
+; CHECK-NEXT: sub
+; CHECK-NEXT: select
+; CHECK-NEXT: ret
+
+ %xord = xor i32 %x, -1
+ %yadd = add i32 %y, 2
+ %cond.i = icmp sge i32 %yadd, %xord
+ %min = select i1 %cond.i, i32 %xord, i32 %yadd
+ %cmp2 = icmp sgt i32 %min, -1
+ %sub = sub i32 0, %min
+ %abs = select i1 %cmp2, i32 %min, i32 %sub
+ ret i32 %abs
+}
+
define <2 x i32> @max_of_nots_vec(<2 x i32> %x, <2 x i32> %y) {
; CHECK-LABEL: @max_of_nots_vec(
; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <2 x i32> %y, zeroinitializer
Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -785,7 +785,9 @@
// This transform is performance neutral if we can elide at least one xor from
// the set of three operands, since we'll be tacking on an xor at the very
// end.
- if (IsFreeOrProfitableToInvert(A, NotA, ElidesXor) &&
+ if (SelectPatternResult::isMinOrMax(SPF1) &&
+ SelectPatternResult::isMinOrMax(SPF2) &&
+ IsFreeOrProfitableToInvert(A, NotA, ElidesXor) &&
IsFreeOrProfitableToInvert(B, NotB, ElidesXor) &&
IsFreeOrProfitableToInvert(C, NotC, ElidesXor) && ElidesXor) {
if (!NotA)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30051.89204.patch
Type: text/x-patch
Size: 1855 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170221/47fc7106/attachment.bin>
More information about the llvm-commits
mailing list