[llvm] r265871 - [X86] Use for loops over types to reduce code for setting up operation actions. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 8 23:31:02 PDT 2016
Author: ctopper
Date: Sat Apr 9 01:31:02 2016
New Revision: 265871
URL: http://llvm.org/viewvc/llvm-project?rev=265871&view=rev
Log:
[X86] Use for loops over types to reduce code for setting up operation actions. NFC
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=265871&r1=265870&r2=265871&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat Apr 9 01:31:02 2016
@@ -1060,29 +1060,17 @@ X86TargetLowering::X86TargetLowering(con
}
if (Subtarget.hasXOP()) {
- setOperationAction(ISD::ROTL, MVT::v16i8, Custom);
- setOperationAction(ISD::ROTL, MVT::v8i16, Custom);
- setOperationAction(ISD::ROTL, MVT::v4i32, Custom);
- setOperationAction(ISD::ROTL, MVT::v2i64, Custom);
- setOperationAction(ISD::ROTL, MVT::v32i8, Custom);
- setOperationAction(ISD::ROTL, MVT::v16i16, Custom);
- setOperationAction(ISD::ROTL, MVT::v8i32, Custom);
- setOperationAction(ISD::ROTL, MVT::v4i64, Custom);
+ for (auto VT : { MVT::v16i8, MVT::v8i16, MVT::v4i32, MVT::v2i64,
+ MVT::v32i8, MVT::v16i16, MVT::v8i32, MVT::v4i64 })
+ setOperationAction(ISD::ROTL, VT, Custom);
// XOP can efficiently perform BITREVERSE with VPPERM.
- setOperationAction(ISD::BITREVERSE, MVT::i8, Custom);
- setOperationAction(ISD::BITREVERSE, MVT::i16, Custom);
- setOperationAction(ISD::BITREVERSE, MVT::i32, Custom);
- setOperationAction(ISD::BITREVERSE, MVT::i64, Custom);
-
- setOperationAction(ISD::BITREVERSE, MVT::v16i8, Custom);
- setOperationAction(ISD::BITREVERSE, MVT::v8i16, Custom);
- setOperationAction(ISD::BITREVERSE, MVT::v4i32, Custom);
- setOperationAction(ISD::BITREVERSE, MVT::v2i64, Custom);
- setOperationAction(ISD::BITREVERSE, MVT::v32i8, Custom);
- setOperationAction(ISD::BITREVERSE, MVT::v16i16, Custom);
- setOperationAction(ISD::BITREVERSE, MVT::v8i32, Custom);
- setOperationAction(ISD::BITREVERSE, MVT::v4i64, Custom);
+ for (auto VT : { MVT::i8, MVT::i16, MVT::i32, MVT::i64 })
+ setOperationAction(ISD::BITREVERSE, VT, Custom);
+
+ for (auto VT : { MVT::v16i8, MVT::v8i16, MVT::v4i32, MVT::v2i64,
+ MVT::v32i8, MVT::v16i16, MVT::v8i32, MVT::v4i64 })
+ setOperationAction(ISD::BITREVERSE, VT, Custom);
}
if (!Subtarget.useSoftFloat() && Subtarget.hasFp256()) {
@@ -1097,31 +1085,20 @@ X86TargetLowering::X86TargetLowering(con
setOperationAction(ISD::LOAD, MVT::v4f64, Legal);
setOperationAction(ISD::LOAD, MVT::v4i64, Legal);
- setOperationAction(ISD::FADD, MVT::v8f32, Legal);
- setOperationAction(ISD::FSUB, MVT::v8f32, Legal);
- setOperationAction(ISD::FMUL, MVT::v8f32, Legal);
- setOperationAction(ISD::FDIV, MVT::v8f32, Legal);
- setOperationAction(ISD::FSQRT, MVT::v8f32, Legal);
- setOperationAction(ISD::FFLOOR, MVT::v8f32, Legal);
- setOperationAction(ISD::FCEIL, MVT::v8f32, Legal);
- setOperationAction(ISD::FTRUNC, MVT::v8f32, Legal);
- setOperationAction(ISD::FRINT, MVT::v8f32, Legal);
- setOperationAction(ISD::FNEARBYINT, MVT::v8f32, Legal);
- setOperationAction(ISD::FNEG, MVT::v8f32, Custom);
- setOperationAction(ISD::FABS, MVT::v8f32, Custom);
-
- setOperationAction(ISD::FADD, MVT::v4f64, Legal);
- setOperationAction(ISD::FSUB, MVT::v4f64, Legal);
- setOperationAction(ISD::FMUL, MVT::v4f64, Legal);
- setOperationAction(ISD::FDIV, MVT::v4f64, Legal);
- setOperationAction(ISD::FSQRT, MVT::v4f64, Legal);
- setOperationAction(ISD::FFLOOR, MVT::v4f64, Legal);
- setOperationAction(ISD::FCEIL, MVT::v4f64, Legal);
- setOperationAction(ISD::FTRUNC, MVT::v4f64, Legal);
- setOperationAction(ISD::FRINT, MVT::v4f64, Legal);
- setOperationAction(ISD::FNEARBYINT, MVT::v4f64, Legal);
- setOperationAction(ISD::FNEG, MVT::v4f64, Custom);
- setOperationAction(ISD::FABS, MVT::v4f64, Custom);
+ for (auto VT : { MVT::v8f32, MVT::v4f64 }) {
+ setOperationAction(ISD::FADD, VT, Legal);
+ setOperationAction(ISD::FSUB, VT, Legal);
+ setOperationAction(ISD::FMUL, VT, Legal);
+ setOperationAction(ISD::FDIV, VT, Legal);
+ setOperationAction(ISD::FSQRT, VT, Legal);
+ setOperationAction(ISD::FFLOOR, VT, Legal);
+ setOperationAction(ISD::FCEIL, VT, Legal);
+ setOperationAction(ISD::FTRUNC, VT, Legal);
+ setOperationAction(ISD::FRINT, VT, Legal);
+ setOperationAction(ISD::FNEARBYINT, VT, Legal);
+ setOperationAction(ISD::FNEG, VT, Custom);
+ setOperationAction(ISD::FABS, VT, Custom);
+ }
// (fp_to_int:v8i16 (v8f32 ..)) requires the result type to be promoted
// even though v8i16 is a legal type.
@@ -1139,14 +1116,11 @@ X86TargetLowering::X86TargetLowering(con
for (MVT VT : MVT::fp_vector_valuetypes())
setLoadExtAction(ISD::EXTLOAD, VT, MVT::v4f32, Legal);
- setOperationAction(ISD::SRL, MVT::v16i16, Custom);
- setOperationAction(ISD::SRL, MVT::v32i8, Custom);
-
- setOperationAction(ISD::SHL, MVT::v16i16, Custom);
- setOperationAction(ISD::SHL, MVT::v32i8, Custom);
-
- setOperationAction(ISD::SRA, MVT::v16i16, Custom);
- setOperationAction(ISD::SRA, MVT::v32i8, Custom);
+ for (auto VT : { MVT::v32i8, MVT::v16i16 }) {
+ setOperationAction(ISD::SRL, VT, Custom);
+ setOperationAction(ISD::SHL, VT, Custom);
+ setOperationAction(ISD::SRA, VT, Custom);
+ }
setOperationAction(ISD::SETCC, MVT::v32i8, Custom);
setOperationAction(ISD::SETCC, MVT::v16i16, Custom);
@@ -1170,39 +1144,23 @@ X86TargetLowering::X86TargetLowering(con
setOperationAction(ISD::TRUNCATE, MVT::v8i16, Custom);
setOperationAction(ISD::TRUNCATE, MVT::v4i32, Custom);
- setOperationAction(ISD::CTPOP, MVT::v32i8, Custom);
- setOperationAction(ISD::CTPOP, MVT::v16i16, Custom);
- setOperationAction(ISD::CTPOP, MVT::v8i32, Custom);
- setOperationAction(ISD::CTPOP, MVT::v4i64, Custom);
-
- setOperationAction(ISD::CTTZ, MVT::v32i8, Custom);
- setOperationAction(ISD::CTTZ, MVT::v16i16, Custom);
- setOperationAction(ISD::CTTZ, MVT::v8i32, Custom);
- setOperationAction(ISD::CTTZ, MVT::v4i64, Custom);
- setOperationAction(ISD::CTTZ_ZERO_UNDEF, MVT::v32i8, Custom);
- setOperationAction(ISD::CTTZ_ZERO_UNDEF, MVT::v16i16, Custom);
- setOperationAction(ISD::CTTZ_ZERO_UNDEF, MVT::v8i32, Custom);
- setOperationAction(ISD::CTTZ_ZERO_UNDEF, MVT::v4i64, Custom);
+ for (auto VT : { MVT::v32i8, MVT::v16i16, MVT::v8i32, MVT::v4i64 }) {
+ setOperationAction(ISD::CTPOP, VT, Custom);
+ setOperationAction(ISD::CTTZ, VT, Custom);
+ setOperationAction(ISD::CTTZ_ZERO_UNDEF, VT, Custom);
+ }
if (Subtarget.hasAnyFMA()) {
- setOperationAction(ISD::FMA, MVT::v8f32, Legal);
- setOperationAction(ISD::FMA, MVT::v4f64, Legal);
- setOperationAction(ISD::FMA, MVT::v4f32, Legal);
- setOperationAction(ISD::FMA, MVT::v2f64, Legal);
- setOperationAction(ISD::FMA, MVT::f32, Legal);
- setOperationAction(ISD::FMA, MVT::f64, Legal);
+ for (auto VT : { MVT::f32, MVT::f64, MVT::v4f32, MVT::v8f32,
+ MVT::v2f64, MVT::v4f64 })
+ setOperationAction(ISD::FMA, VT, Legal);
}
if (Subtarget.hasInt256()) {
- setOperationAction(ISD::ADD, MVT::v4i64, Legal);
- setOperationAction(ISD::ADD, MVT::v8i32, Legal);
- setOperationAction(ISD::ADD, MVT::v16i16, Legal);
- setOperationAction(ISD::ADD, MVT::v32i8, Legal);
-
- setOperationAction(ISD::SUB, MVT::v4i64, Legal);
- setOperationAction(ISD::SUB, MVT::v8i32, Legal);
- setOperationAction(ISD::SUB, MVT::v16i16, Legal);
- setOperationAction(ISD::SUB, MVT::v32i8, Legal);
+ for (auto VT : { MVT::v32i8, MVT::v16i16, MVT::v8i32, MVT::v4i64 }) {
+ setOperationAction(ISD::ADD, VT, Legal);
+ setOperationAction(ISD::SUB, VT, Legal);
+ }
setOperationAction(ISD::MUL, MVT::v4i64, Custom);
setOperationAction(ISD::MUL, MVT::v8i32, Legal);
@@ -1217,18 +1175,12 @@ X86TargetLowering::X86TargetLowering(con
setOperationAction(ISD::MULHU, MVT::v32i8, Custom);
setOperationAction(ISD::MULHS, MVT::v32i8, Custom);
- setOperationAction(ISD::SMAX, MVT::v32i8, Legal);
- setOperationAction(ISD::SMAX, MVT::v16i16, Legal);
- setOperationAction(ISD::SMAX, MVT::v8i32, Legal);
- setOperationAction(ISD::UMAX, MVT::v32i8, Legal);
- setOperationAction(ISD::UMAX, MVT::v16i16, Legal);
- setOperationAction(ISD::UMAX, MVT::v8i32, Legal);
- setOperationAction(ISD::SMIN, MVT::v32i8, Legal);
- setOperationAction(ISD::SMIN, MVT::v16i16, Legal);
- setOperationAction(ISD::SMIN, MVT::v8i32, Legal);
- setOperationAction(ISD::UMIN, MVT::v32i8, Legal);
- setOperationAction(ISD::UMIN, MVT::v16i16, Legal);
- setOperationAction(ISD::UMIN, MVT::v8i32, Legal);
+ for (auto VT : { MVT::v32i8, MVT::v16i16, MVT::v8i32 }) {
+ setOperationAction(ISD::SMAX, VT, Legal);
+ setOperationAction(ISD::UMAX, VT, Legal);
+ setOperationAction(ISD::SMIN, VT, Legal);
+ setOperationAction(ISD::UMIN, VT, Legal);
+ }
setOperationAction(ISD::SIGN_EXTEND_VECTOR_INREG, MVT::v4i64, Custom);
setOperationAction(ISD::SIGN_EXTEND_VECTOR_INREG, MVT::v8i32, Custom);
@@ -1253,15 +1205,10 @@ X86TargetLowering::X86TargetLowering(con
setLoadExtAction(ISD::ZEXTLOAD, MVT::v4i64, MVT::v4i16, Legal);
setLoadExtAction(ISD::ZEXTLOAD, MVT::v4i64, MVT::v4i32, Legal);
} else {
- setOperationAction(ISD::ADD, MVT::v4i64, Custom);
- setOperationAction(ISD::ADD, MVT::v8i32, Custom);
- setOperationAction(ISD::ADD, MVT::v16i16, Custom);
- setOperationAction(ISD::ADD, MVT::v32i8, Custom);
-
- setOperationAction(ISD::SUB, MVT::v4i64, Custom);
- setOperationAction(ISD::SUB, MVT::v8i32, Custom);
- setOperationAction(ISD::SUB, MVT::v16i16, Custom);
- setOperationAction(ISD::SUB, MVT::v32i8, Custom);
+ for (auto VT : { MVT::v32i8, MVT::v16i16, MVT::v8i32, MVT::v4i64 }) {
+ setOperationAction(ISD::ADD, VT, Custom);
+ setOperationAction(ISD::SUB, VT, Custom);
+ }
setOperationAction(ISD::MUL, MVT::v4i64, Custom);
setOperationAction(ISD::MUL, MVT::v8i32, Custom);
@@ -1276,30 +1223,21 @@ X86TargetLowering::X86TargetLowering(con
setOperationAction(ISD::MULHU, MVT::v32i8, Custom);
setOperationAction(ISD::MULHS, MVT::v32i8, Custom);
- setOperationAction(ISD::SMAX, MVT::v32i8, Custom);
- setOperationAction(ISD::SMAX, MVT::v16i16, Custom);
- setOperationAction(ISD::SMAX, MVT::v8i32, Custom);
- setOperationAction(ISD::UMAX, MVT::v32i8, Custom);
- setOperationAction(ISD::UMAX, MVT::v16i16, Custom);
- setOperationAction(ISD::UMAX, MVT::v8i32, Custom);
- setOperationAction(ISD::SMIN, MVT::v32i8, Custom);
- setOperationAction(ISD::SMIN, MVT::v16i16, Custom);
- setOperationAction(ISD::SMIN, MVT::v8i32, Custom);
- setOperationAction(ISD::UMIN, MVT::v32i8, Custom);
- setOperationAction(ISD::UMIN, MVT::v16i16, Custom);
- setOperationAction(ISD::UMIN, MVT::v8i32, Custom);
+ for (auto VT : { MVT::v32i8, MVT::v16i16, MVT::v8i32 }) {
+ setOperationAction(ISD::SMAX, VT, Custom);
+ setOperationAction(ISD::UMAX, VT, Custom);
+ setOperationAction(ISD::SMIN, VT, Custom);
+ setOperationAction(ISD::UMIN, VT, Custom);
+ }
}
// In the customized shift lowering, the legal cases in AVX2 will be
// recognized.
- setOperationAction(ISD::SRL, MVT::v4i64, Custom);
- setOperationAction(ISD::SRL, MVT::v8i32, Custom);
-
- setOperationAction(ISD::SHL, MVT::v4i64, Custom);
- setOperationAction(ISD::SHL, MVT::v8i32, Custom);
-
- setOperationAction(ISD::SRA, MVT::v4i64, Custom);
- setOperationAction(ISD::SRA, MVT::v8i32, Custom);
+ for (auto VT : { MVT::v8i32, MVT::v4i64 }) {
+ setOperationAction(ISD::SRL, VT, Custom);
+ setOperationAction(ISD::SHL, VT, Custom);
+ setOperationAction(ISD::SRA, VT, Custom);
+ }
// Custom lower several nodes for 256-bit types.
for (MVT VT : MVT::vector_valuetypes()) {
@@ -1396,23 +1334,17 @@ X86TargetLowering::X86TargetLowering(con
setLoadExtAction(ISD::EXTLOAD, VT, MaskVT, Custom);
setTruncStoreAction(VT, MaskVT, Custom);
}
- setOperationAction(ISD::FADD, MVT::v16f32, Legal);
- setOperationAction(ISD::FSUB, MVT::v16f32, Legal);
- setOperationAction(ISD::FMUL, MVT::v16f32, Legal);
- setOperationAction(ISD::FDIV, MVT::v16f32, Legal);
- setOperationAction(ISD::FSQRT, MVT::v16f32, Legal);
- setOperationAction(ISD::FNEG, MVT::v16f32, Custom);
- setOperationAction(ISD::FABS, MVT::v16f32, Custom);
-
- setOperationAction(ISD::FADD, MVT::v8f64, Legal);
- setOperationAction(ISD::FSUB, MVT::v8f64, Legal);
- setOperationAction(ISD::FMUL, MVT::v8f64, Legal);
- setOperationAction(ISD::FDIV, MVT::v8f64, Legal);
- setOperationAction(ISD::FSQRT, MVT::v8f64, Legal);
- setOperationAction(ISD::FNEG, MVT::v8f64, Custom);
- setOperationAction(ISD::FABS, MVT::v8f64, Custom);
- setOperationAction(ISD::FMA, MVT::v8f64, Legal);
- setOperationAction(ISD::FMA, MVT::v16f32, Legal);
+
+ for (MVT VT : { MVT::v16f32, MVT::v8f64 }) {
+ setOperationAction(ISD::FADD, VT, Legal);
+ setOperationAction(ISD::FSUB, VT, Legal);
+ setOperationAction(ISD::FMUL, VT, Legal);
+ setOperationAction(ISD::FDIV, VT, Legal);
+ setOperationAction(ISD::FSQRT, VT, Legal);
+ setOperationAction(ISD::FNEG, VT, Custom);
+ setOperationAction(ISD::FABS, VT, Custom);
+ setOperationAction(ISD::FMA, VT, Legal);
+ }
setOperationAction(ISD::FP_TO_SINT, MVT::v16i32, Legal);
setOperationAction(ISD::FP_TO_UINT, MVT::v16i32, Legal);
@@ -1503,16 +1435,13 @@ X86TargetLowering::X86TargetLowering(con
setOperationAction(ISD::SIGN_EXTEND, MVT::v4i32, Custom);
setOperationAction(ISD::SIGN_EXTEND, MVT::v2i64, Custom);
}
- setOperationAction(ISD::FFLOOR, MVT::v16f32, Legal);
- setOperationAction(ISD::FFLOOR, MVT::v8f64, Legal);
- setOperationAction(ISD::FCEIL, MVT::v16f32, Legal);
- setOperationAction(ISD::FCEIL, MVT::v8f64, Legal);
- setOperationAction(ISD::FTRUNC, MVT::v16f32, Legal);
- setOperationAction(ISD::FTRUNC, MVT::v8f64, Legal);
- setOperationAction(ISD::FRINT, MVT::v16f32, Legal);
- setOperationAction(ISD::FRINT, MVT::v8f64, Legal);
- setOperationAction(ISD::FNEARBYINT, MVT::v16f32, Legal);
- setOperationAction(ISD::FNEARBYINT, MVT::v8f64, Legal);
+ for (auto VT : { MVT::v16f32, MVT::v8f64 }) {
+ setOperationAction(ISD::FFLOOR, VT, Legal);
+ setOperationAction(ISD::FCEIL, VT, Legal);
+ setOperationAction(ISD::FTRUNC, VT, Legal);
+ setOperationAction(ISD::FRINT, VT, Legal);
+ setOperationAction(ISD::FNEARBYINT, VT, Legal);
+ }
setOperationAction(ISD::CONCAT_VECTORS, MVT::v8f64, Custom);
setOperationAction(ISD::CONCAT_VECTORS, MVT::v8i64, Custom);
More information about the llvm-commits
mailing list