diff --git a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp --- a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp +++ b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp @@ -1517,8 +1517,11 @@ setMinimumJumpTableEntries(std::numeric_limits::max()); setOperationAction(ISD::BR_JT, MVT::Other, Expand); - setOperationAction(ISD::ABS, MVT::i32, Legal); - setOperationAction(ISD::ABS, MVT::i64, Legal); + for (unsigned LegalIntOp : + {ISD::ABS, ISD::SMIN, ISD::SMAX, ISD::UMIN, ISD::UMAX}) { + setOperationAction(LegalIntOp, MVT::i32, Legal); + setOperationAction(LegalIntOp, 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. @@ -1683,6 +1686,13 @@ setOperationAction(ISD::SPLAT_VECTOR, NativeVT, Legal); } + for (MVT VT : {MVT::v8i8, MVT::v4i16, MVT::v2i32}) { + setOperationAction(ISD::SMIN, VT, Legal); + setOperationAction(ISD::SMAX, VT, Legal); + setOperationAction(ISD::UMIN, VT, Legal); + setOperationAction(ISD::UMAX, VT, Legal); + } + // Custom lower unaligned loads. // Also, for both loads and stores, verify the alignment of the address // in case it is a compile-time constant. This is a usability feature to diff --git a/llvm/lib/Target/Hexagon/HexagonPatterns.td b/llvm/lib/Target/Hexagon/HexagonPatterns.td --- a/llvm/lib/Target/Hexagon/HexagonPatterns.td +++ b/llvm/lib/Target/Hexagon/HexagonPatterns.td @@ -366,12 +366,14 @@ def: Pat<(Ty2 (bitconvert (Ty1 RC:$Val))), (Ty2 RC:$Val)>; } - // Frags for commonly used SDNodes. def Add: pf2; def And: pf2; def Sra: pf2; def Sub: pf2; def Or: pf2; def Srl: pf2; def Mul: pf2; def Xor: pf2; def Shl: pf2; +def Smin: pf2; def Smax: pf2; +def Umin: pf2; def Umax: pf2; + def Rol: pf2; // --(1) Immediate ------------------------------------------------------- @@ -924,25 +926,14 @@ defm: SelMinMax16_pats; } -let AddedComplexity = 200 in { - defm: MinMax_pats; - defm: MinMax_pats; - defm: MinMax_pats; - defm: MinMax_pats; - defm: MinMax_pats; - defm: MinMax_pats; - defm: MinMax_pats; - defm: MinMax_pats; - - defm: MinMax_pats; - defm: MinMax_pats; - defm: MinMax_pats; - defm: MinMax_pats; - defm: MinMax_pats; - defm: MinMax_pats; - defm: MinMax_pats; - defm: MinMax_pats; -} +def: OpR_RR_pat; +def: OpR_RR_pat; +def: OpR_RR_pat; +def: OpR_RR_pat; +def: OpR_RR_pat; +def: OpR_RR_pat; +def: OpR_RR_pat; +def: OpR_RR_pat; let AddedComplexity = 100 in { defm: MinMax_pats; @@ -958,18 +949,20 @@ defm: MinMax_pats; } -defm: MinMax_pats; -defm: MinMax_pats; -defm: MinMax_pats; -defm: MinMax_pats; -defm: MinMax_pats; -defm: MinMax_pats; -defm: MinMax_pats; -defm: MinMax_pats; -defm: MinMax_pats; -defm: MinMax_pats; -defm: MinMax_pats; -defm: MinMax_pats; +def: OpR_RR_pat; +def: OpR_RR_pat; +def: OpR_RR_pat; +def: OpR_RR_pat; + +def: OpR_RR_pat; +def: OpR_RR_pat; +def: OpR_RR_pat; +def: OpR_RR_pat; + +def: OpR_RR_pat; +def: OpR_RR_pat; +def: OpR_RR_pat; +def: OpR_RR_pat; // --(7) Insert/extract -------------------------------------------------- // diff --git a/llvm/test/CodeGen/Hexagon/isel-minmax-v64bit.ll b/llvm/test/CodeGen/Hexagon/isel-minmax-v64bit.ll --- a/llvm/test/CodeGen/Hexagon/isel-minmax-v64bit.ll +++ b/llvm/test/CodeGen/Hexagon/isel-minmax-v64bit.ll @@ -3,7 +3,7 @@ ; min ; CHECK-LABEL: test_00: -; CHECK: r1:0 = vminb(r3:2,r1:0) +; CHECK: r1:0 = vminb(r1:0,r3:2) define <8 x i8> @test_00(<8 x i8> %a0, <8 x i8> %a1) #0 { %v0 = icmp slt <8 x i8> %a0, %a1 %v1 = select <8 x i1> %v0, <8 x i8> %a0, <8 x i8> %a1 @@ -19,7 +19,7 @@ } ; CHECK-LABEL: test_02: -; CHECK: r1:0 = vminh(r3:2,r1:0) +; CHECK: r1:0 = vminh(r1:0,r3:2) define <4 x i16> @test_02(<4 x i16> %a0, <4 x i16> %a1) #0 { %v0 = icmp slt <4 x i16> %a0, %a1 %v1 = select <4 x i1> %v0, <4 x i16> %a0, <4 x i16> %a1 @@ -35,7 +35,7 @@ } ; CHECK-LABEL: test_04: -; CHECK: r1:0 = vminw(r3:2,r1:0) +; CHECK: r1:0 = vminw(r1:0,r3:2) define <2 x i32> @test_04(<2 x i32> %a0, <2 x i32> %a1) #0 { %v0 = icmp slt <2 x i32> %a0, %a1 %v1 = select <2 x i1> %v0, <2 x i32> %a0, <2 x i32> %a1 @@ -53,7 +53,7 @@ ; minu ; CHECK-LABEL: test_06: -; CHECK: r1:0 = vminub(r3:2,r1:0) +; CHECK: r1:0 = vminub(r1:0,r3:2) define <8 x i8> @test_06(<8 x i8> %a0, <8 x i8> %a1) #0 { %v0 = icmp ult <8 x i8> %a0, %a1 %v1 = select <8 x i1> %v0, <8 x i8> %a0, <8 x i8> %a1 @@ -69,7 +69,7 @@ } ; CHECK-LABEL: test_08: -; CHECK: r1:0 = vminuh(r3:2,r1:0) +; CHECK: r1:0 = vminuh(r1:0,r3:2) define <4 x i16> @test_08(<4 x i16> %a0, <4 x i16> %a1) #0 { %v0 = icmp ult <4 x i16> %a0, %a1 %v1 = select <4 x i1> %v0, <4 x i16> %a0, <4 x i16> %a1 @@ -85,7 +85,7 @@ } ; CHECK-LABEL: test_0a: -; CHECK: r1:0 = vminuw(r3:2,r1:0) +; CHECK: r1:0 = vminuw(r1:0,r3:2) define <2 x i32> @test_0a(<2 x i32> %a0, <2 x i32> %a1) #0 { %v0 = icmp ult <2 x i32> %a0, %a1 %v1 = select <2 x i1> %v0, <2 x i32> %a0, <2 x i32> %a1 @@ -111,7 +111,7 @@ } ; CHECK-LABEL: test_0d: -; CHECK: r1:0 = vmaxb(r3:2,r1:0) +; CHECK: r1:0 = vmaxb(r1:0,r3:2) define <8 x i8> @test_0d(<8 x i8> %a0, <8 x i8> %a1) #0 { %v0 = icmp sge <8 x i8> %a0, %a1 %v1 = select <8 x i1> %v0, <8 x i8> %a0, <8 x i8> %a1 @@ -127,7 +127,7 @@ } ; CHECK-LABEL: test_0f: -; CHECK: r1:0 = vmaxh(r3:2,r1:0) +; CHECK: r1:0 = vmaxh(r1:0,r3:2) define <4 x i16> @test_0f(<4 x i16> %a0, <4 x i16> %a1) #0 { %v0 = icmp sge <4 x i16> %a0, %a1 %v1 = select <4 x i1> %v0, <4 x i16> %a0, <4 x i16> %a1 @@ -143,7 +143,7 @@ } ; CHECK-LABEL: test_11: -; CHECK: r1:0 = vmaxw(r3:2,r1:0) +; CHECK: r1:0 = vmaxw(r1:0,r3:2) define <2 x i32> @test_11(<2 x i32> %a0, <2 x i32> %a1) #0 { %v0 = icmp sge <2 x i32> %a0, %a1 %v1 = select <2 x i1> %v0, <2 x i32> %a0, <2 x i32> %a1 @@ -161,7 +161,7 @@ } ; CHECK-LABEL: test_13: -; CHECK: r1:0 = vmaxub(r3:2,r1:0) +; CHECK: r1:0 = vmaxub(r1:0,r3:2) define <8 x i8> @test_13(<8 x i8> %a0, <8 x i8> %a1) #0 { %v0 = icmp uge <8 x i8> %a0, %a1 %v1 = select <8 x i1> %v0, <8 x i8> %a0, <8 x i8> %a1 @@ -177,7 +177,7 @@ } ; CHECK-LABEL: test_15: -; CHECK: r1:0 = vmaxuh(r3:2,r1:0) +; CHECK: r1:0 = vmaxuh(r1:0,r3:2) define <4 x i16> @test_15(<4 x i16> %a0, <4 x i16> %a1) #0 { %v0 = icmp uge <4 x i16> %a0, %a1 %v1 = select <4 x i1> %v0, <4 x i16> %a0, <4 x i16> %a1 @@ -193,7 +193,7 @@ } ; CHECK-LABEL: test_17: -; CHECK: r1:0 = vmaxuw(r3:2,r1:0) +; CHECK: r1:0 = vmaxuw(r1:0,r3:2) define <2 x i32> @test_17(<2 x i32> %a0, <2 x i32> %a1) #0 { %v0 = icmp uge <2 x i32> %a0, %a1 %v1 = select <2 x i1> %v0, <2 x i32> %a0, <2 x i32> %a1