summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>2018-06-12 21:51:49 +0000
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>2018-06-12 21:51:49 +0000
commit82d284c1d28b2694acc461efec09e12193ce1b7d (patch)
treeb568e5f3c2b251c9e075f324dd6f7ecd1dcba3d8 /llvm/lib/Target
parent4eed6cc43369e2f29a9f4ddfe843fb126657923b (diff)
downloadbcm5719-llvm-82d284c1d28b2694acc461efec09e12193ce1b7d.tar.gz
bcm5719-llvm-82d284c1d28b2694acc461efec09e12193ce1b7d.zip
[DAGCombiner] Recognize more patterns for ABS
Differential Revision: https://reviews.llvm.org/D47831 llvm-svn: 334553
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/ARM/ARMInstrNEON.td20
-rw-r--r--llvm/lib/Target/Hexagon/HexagonISelLowering.cpp3
-rw-r--r--llvm/lib/Target/Hexagon/HexagonPatterns.td16
3 files changed, 11 insertions, 28 deletions
diff --git a/llvm/lib/Target/ARM/ARMInstrNEON.td b/llvm/lib/Target/ARM/ARMInstrNEON.td
index 8010352d343..58fcf21dd19 100644
--- a/llvm/lib/Target/ARM/ARMInstrNEON.td
+++ b/llvm/lib/Target/ARM/ARMInstrNEON.td
@@ -5392,23 +5392,19 @@ defm VABDLs : N3VLIntExt_QHS<0,1,0b0111,0, IIC_VSUBi4Q,
defm VABDLu : N3VLIntExt_QHS<1,1,0b0111,0, IIC_VSUBi4Q,
"vabdl", "u", int_arm_neon_vabdu, zext, 1>;
+def : Pat<(v8i16 (abs (sub (zext (v8i8 DPR:$opA)), (zext (v8i8 DPR:$opB))))),
+ (VABDLuv8i16 DPR:$opA, DPR:$opB)>;
+def : Pat<(v4i32 (abs (sub (zext (v4i16 DPR:$opA)), (zext (v4i16 DPR:$opB))))),
+ (VABDLuv4i32 DPR:$opA, DPR:$opB)>;
+
+// ISD::ABS is not legal for v2i64, so VABDL needs to be matched from the
+// shift/xor pattern for ABS.
+
def abd_shr :
PatFrag<(ops node:$in1, node:$in2, node:$shift),
(NEONvshrs (sub (zext node:$in1),
(zext node:$in2)), (i32 $shift))>;
-def : Pat<(xor (v4i32 (bitconvert (v8i16 (abd_shr (v8i8 DPR:$opA), (v8i8 DPR:$opB), 15)))),
- (v4i32 (bitconvert (v8i16 (add (sub (zext (v8i8 DPR:$opA)),
- (zext (v8i8 DPR:$opB))),
- (v8i16 (abd_shr (v8i8 DPR:$opA), (v8i8 DPR:$opB), 15))))))),
- (VABDLuv8i16 DPR:$opA, DPR:$opB)>;
-
-def : Pat<(xor (v4i32 (abd_shr (v4i16 DPR:$opA), (v4i16 DPR:$opB), 31)),
- (v4i32 (add (sub (zext (v4i16 DPR:$opA)),
- (zext (v4i16 DPR:$opB))),
- (abd_shr (v4i16 DPR:$opA), (v4i16 DPR:$opB), 31)))),
- (VABDLuv4i32 DPR:$opA, DPR:$opB)>;
-
def : Pat<(xor (v4i32 (bitconvert (v2i64 (abd_shr (v2i32 DPR:$opA), (v2i32 DPR:$opB), 63)))),
(v4i32 (bitconvert (v2i64 (add (sub (zext (v2i32 DPR:$opA)),
(zext (v2i32 DPR:$opB))),
diff --git a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
index 4fe6e3a9621..bf3a7b6d472 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -1327,6 +1327,9 @@ HexagonTargetLowering::HexagonTargetLowering(const TargetMachine &TM,
setMinimumJumpTableEntries(std::numeric_limits<int>::max());
setOperationAction(ISD::BR_JT, MVT::Other, Expand);
+ setOperationAction(ISD::ABS, MVT::i32, Legal);
+ setOperationAction(ISD::ABS, MVT::i64, Legal);
+
// Hexagon has A4_addp_c and A4_subp_c that take and generate a carry bit,
// but they only operate on i64.
for (MVT VT : MVT::integer_valuetypes()) {
diff --git a/llvm/lib/Target/Hexagon/HexagonPatterns.td b/llvm/lib/Target/Hexagon/HexagonPatterns.td
index 30ee2fb89f4..b1f1c59d22a 100644
--- a/llvm/lib/Target/Hexagon/HexagonPatterns.td
+++ b/llvm/lib/Target/Hexagon/HexagonPatterns.td
@@ -1194,22 +1194,6 @@ let Predicates = [HasV5T] in {
(i32 (LoReg $Rs)))>;
}
-let AddedComplexity = 50 in
-multiclass Abs_pat<InstHexagon MI, PatFrag RsPred, int Sh> {
- // Let y = x >> 31 (for 32-bit), i.e. the sign bit repeated.
- // abs(x) = (x + y) ^ y
- def: Pat<(xor (add (sra RsPred:$Rs, (i32 Sh)), RsPred:$Rs),
- (sra RsPred:$Rs, (i32 Sh))),
- (MI RsPred:$Rs)>;
- // abs(x) = (x ^ y) - y
- def: Pat<(sub (xor RsPred:$Rs, (sra RsPred:$Rs, (i32 Sh))),
- (sra RsPred:$Rs, (i32 Sh))),
- (MI RsPred:$Rs)>;
-}
-
-defm: Abs_pat<A2_abs, I32, 31>;
-defm: Abs_pat<A2_absp, I64, 63>;
-
def: Pat<(add I32:$Rs, anyimm:$s16), (A2_addi I32:$Rs, imm:$s16)>;
def: Pat<(or I32:$Rs, anyimm:$s10), (A2_orir I32:$Rs, imm:$s10)>;
def: Pat<(and I32:$Rs, anyimm:$s10), (A2_andir I32:$Rs, imm:$s10)>;
OpenPOWER on IntegriCloud