diff --git a/gcc/config/rs6000/dfp.md b/gcc/config/rs6000/dfp.md
index 5ed8a73ac51..254c22a5c20 100644
--- a/gcc/config/rs6000/dfp.md
+++ b/gcc/config/rs6000/dfp.md
@@ -271,7 +271,8 @@
    UNSPEC_DIEX
    UNSPEC_DSCLI
    UNSPEC_DTSTSFI
-   UNSPEC_DSCRI])
+   UNSPEC_DSCRI
+   UNSPEC_DQUAN])
 
 (define_code_iterator DFP_TEST [eq lt gt unordered])
 
@@ -395,3 +396,25 @@
   "dscri<q> %0,%1,%2"
   [(set_attr "type" "dfp")
    (set_attr "size" "<bits>")])
+
+(define_insn "dfp_quan_<mode>"
+  [(set (match_operand:DDTD 0 "gpc_reg_operand" "=d")
+        (unspec:DDTD [(match_operand:DDTD 1 "gpc_reg_operand" "d")
+		      (match_operand:DDTD 2 "gpc_reg_operand" "d")
+                      (match_operand:QI 3 "immediate_operand" "i")]
+                     UNSPEC_DQUAN))]
+  "TARGET_DFP"
+  "dqua<q> %0,%1,%2,%3"
+  [(set_attr "type" "dfp")
+   (set_attr "size" "<bits>")])
+
+(define_insn "dfp_quan_i<mode>"
+  [(set (match_operand:DDTD 0 "gpc_reg_operand" "=d")
+        (unspec:DDTD [(match_operand:SI 1 "const_int_operand" "n")
+		      (match_operand:DDTD 2 "gpc_reg_operand" "d")
+                      (match_operand:SI 3 "immediate_operand" "i")]
+                     UNSPEC_DQUAN))]
+  "TARGET_DFP"
+  "dquai<q> %1,%0,%2,%3"
+  [(set_attr "type" "dfp")
+   (set_attr "size" "<bits>")])
diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def
index 35c4cdf74c5..36a56311643 100644
--- a/gcc/config/rs6000/rs6000-builtins.def
+++ b/gcc/config/rs6000/rs6000-builtins.def
@@ -2983,6 +2983,21 @@
   const unsigned long long __builtin_unpack_dec128 (_Decimal128, const int<1>);
     UNPACK_TD unpacktd {}
 
+  const _Decimal64 __builtin_dfp_quantize_64 (_Decimal64, _Decimal64, \
+					      const int<2>);
+    DFPQUAN_64 dfp_quan_dd {}
+
+  const _Decimal64 __builtin_dfp_quantize_64i (const int<5>, _Decimal64, \
+					         const int<2>);
+    DFPQUAN_64i dfp_quan_idd {}
+
+  const _Decimal128 __builtin_dfp_quantize_128 (_Decimal128, _Decimal128, \
+						  const int<2>);
+    DFPQUAN_128 dfp_quan_td {}
+
+  const _Decimal128 __builtin_dfp_quantize_128i (const int<5>, _Decimal128, \
+						   const int<2>);
+    DFPQUAN_128i dfp_quan_itd {}
 
 [crypto]
   const vull __builtin_crypto_vcipher (vull, vull);
diff --git a/gcc/config/rs6000/rs6000-overload.def b/gcc/config/rs6000/rs6000-overload.def
index b83946f5ad8..3bb1bedd69d 100644
--- a/gcc/config/rs6000/rs6000-overload.def
+++ b/gcc/config/rs6000/rs6000-overload.def
@@ -195,6 +195,18 @@
   unsigned long long __builtin_cmpb (unsigned long long, unsigned long long);
     CMPB
 
+[DFPQUAN_64, dfp_quan_64, __builtin_dfp_quantize]
+  _Decimal64 __builtin_dfp_quantize (_Decimal64, _Decimal64, const int);
+    DFPQUAN_64
+  _Decimal64 __builtin_dfp_quantize (const int, _Decimal64, const int);
+    DFPQUAN_64i
+
+[DFPQUAN_128, dfp_quan_128, __builtin_dfpq_quantize]
+  _Decimal128 __builtin_dfpq_quantize (_Decimal128, _Decimal128, const int);
+    DFPQUAN_128
+  _Decimal128 __builtin_dfpq_quantize (const int, _Decimal128, const int);
+    DFPQUAN_128i
+
 [VEC_ABS, vec_abs, __builtin_vec_abs]
   vsc __builtin_vec_abs (vsc);
     ABS_V16QI
diff --git a/gcc/testsuite/gcc.target/powerpc/builtin-dfp-quantize-runnable.c b/gcc/testsuite/gcc.target/powerpc/builtin-dfp-quantize-runnable.c
new file mode 100644
index 00000000000..f4ba7236fe3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/builtin-dfp-quantize-runnable.c
@@ -0,0 +1,198 @@
+/* { dg-do run } */
+/* { dg-require-effective-target  dfp } */
+/* { dg-options "-O2 -save-temps" } */
+
+
+#define DEBUG 0
+
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+#include <float.h>
+
+void abort (void);
+
+int main()
+{
+#define IMM2  2
+#define IMM3  3
+#define IMM4  4
+
+  _Decimal64 srcA_dfp64, srcB_dfp64;
+  _Decimal64 result_dfp64;
+  _Decimal64 expected_result_dfp64;
+  _Decimal128 srcA_dfp128, srcB_dfp128;
+  _Decimal128 result_dfp128;
+  _Decimal128 expected_result_dfp128;
+
+  /* Third argument of quantize built-ins is the rounding mode value (RMC).
+     
+     RMC    Rounding Mode
+     00     Round toward 0
+     01     Round to -infinity
+     10     Round to nearest, ties toward 0
+     11     Round according to DRN      */
+
+
+  /* Tests for quantize with 64-bit DFP variable.  */
+  srcA_dfp64 = 100.0df;
+  srcB_dfp64 = 300.456789df;
+  expected_result_dfp64 = 300.5df;
+
+  result_dfp64 = __builtin_dfp_quantize (srcA_dfp64, srcB_dfp64, 0x0);
+
+  if (result_dfp64 != expected_result_dfp64)
+#if DEBUG
+    printf("DFP 64-bit quantize of variable, RMC = 0 result does not match expected result\n");
+#else
+    abort();
+#endif
+
+  srcA_dfp64 = 100.00df;
+  srcB_dfp64 = 300.456789df;
+  expected_result_dfp64 = 300.45df;
+
+  result_dfp64 = __builtin_dfp_quantize (srcA_dfp64, srcB_dfp64, 0x1);
+
+  if (result_dfp64 != expected_result_dfp64)
+#if DEBUG
+    printf("DFP 64-bit quantize of variable, RMC = 1 result does not match expected result\n");
+#else
+    abort();
+#endif
+
+  srcA_dfp64 = 100.001df;
+  srcB_dfp64 = 3001.456789df;
+  expected_result_dfp64 = 3001.457df;
+
+  result_dfp64 = __builtin_dfp_quantize (srcA_dfp64, srcB_dfp64, 0x2);
+
+  if (result_dfp64 != expected_result_dfp64)
+#if DEBUG
+    printf("DFP 64-bit quantize of variable, RMC = 2 result does not match expected result\n");
+#else
+    abort();
+#endif
+
+  /* Tests for 64-bit quantize with immediate value.  */
+
+  srcB_dfp64 = 10.4567df;
+  expected_result_dfp64 = 000.0df;
+
+  result_dfp64 = __builtin_dfp_quantize (IMM2, srcB_dfp64, 0x0);
+
+  if (result_dfp64 != expected_result_dfp64)
+#if DEBUG
+    printf("DFP 64-bit quantize immediate, RMC = 0 result does not match expected result\n");
+#else
+    abort();
+#endif
+
+  srcB_dfp64 = 104567.891df;
+  expected_result_dfp64 = 100000.0df;
+
+  result_dfp64 = __builtin_dfp_quantize (IMM4, srcB_dfp64, 0x1);
+
+  if (result_dfp64 != expected_result_dfp64)
+#if DEBUG
+    printf("DFP 64-bit quantize immediate, RMC = 1 result does not match expected result\n");
+#else
+    abort();
+#endif
+
+  srcB_dfp64 = 109876.54321df;
+  expected_result_dfp64 = 109900.0df;
+
+  result_dfp64 = __builtin_dfp_quantize (IMM2, srcB_dfp64, 0x2);
+
+  if (result_dfp64 != expected_result_dfp64)
+#if DEBUG
+    printf("DFP 64-bit quantize immediate, RMC = 2 result does not match expected result\n");
+#else
+    abort();
+#endif
+
+  /* Tests for quantize 128-bit DFP variable.  */
+  srcA_dfp128 = 0.018df;
+  srcB_dfp128 = 50000.18345df;
+  expected_result_dfp128 = 50000.180df;
+
+  result_dfp128 = __builtin_dfpq_quantize (srcA_dfp128, srcB_dfp128, 0x0);
+  
+  if (result_dfp128 != expected_result_dfp128)
+#if DEBUG
+    printf("DFP 128-bit quantize variable, RMC = 0 result does not match expected result\n");
+#else
+    abort();
+#endif
+
+  srcA_dfp128 = 8.01df;
+  srcB_dfp128 = 50000.18345df;
+  expected_result_dfp128 = 50000.18df;
+
+  result_dfp128 = __builtin_dfpq_quantize (srcA_dfp128, srcB_dfp128, 0x1);
+  
+  if (result_dfp128 != expected_result_dfp128)
+#if DEBUG
+    printf("DFP 128-bit quantize variable, RMC = 1 result does not match expected result\n");
+#else
+    abort();
+#endif
+
+  srcA_dfp128 = 0.1234df;
+  srcB_dfp128 = 50000.18346789df;
+  expected_result_dfp128 = 50000.1800df;
+
+  result_dfp128 = __builtin_dfpq_quantize (srcA_dfp128, srcB_dfp128, 0x2);
+  
+  if (result_dfp128 != expected_result_dfp128)
+#if DEBUG
+    printf("DFP 128-bit quantize variable, RMC = 2 result does not match expected result\n");
+#else
+    abort();
+#endif
+
+  /* Tests for 128-bit quantize with immediate value.  */
+  srcB_dfp128 = 1234.18345df;
+  expected_result_dfp128 = 1200.0df;
+
+  result_dfp128 = __builtin_dfpq_quantize (IMM2, srcB_dfp128, 0x0);
+
+  if (result_dfp128 != expected_result_dfp128)
+#if DEBUG
+    printf("DFP 128-bit quantize immediate, RMC = 0 result does not match expected result\n");
+#else
+    abort();
+#endif
+
+  srcB_dfp128 = 123456.18345df;
+  expected_result_dfp128 = 120000.0df;
+
+  result_dfp128 = __builtin_dfpq_quantize (IMM4, srcB_dfp128, 0x1);
+
+  if (result_dfp128 != expected_result_dfp128)
+#if DEBUG
+    printf("DFP 128-bit quantize immediate, RMC = 1 result does not match expected result\n");
+#else
+    abort();
+#endif
+
+  srcB_dfp128 = 12361834.5df;
+  expected_result_dfp128 = 12362000.0df;
+
+  result_dfp128 = __builtin_dfpq_quantize (IMM3, srcB_dfp128, 0x2);
+
+  if (result_dfp128 != expected_result_dfp128)
+#if DEBUG
+    printf("DFP 128-bit quantize immediate, RMC = 2 result does not match expected result\n");
+#else
+    abort();
+#endif
+
+    return 0;
+}
+
+/* { dg-final { scan-assembler-times {\mdqua\M}   3 } } */
+/* { dg-final { scan-assembler-times {\mdquai\M}  3 } } */
+/* { dg-final { scan-assembler-times {\mdquaq\M}  3 } } */
+/* { dg-final { scan-assembler-times {\mdquaiq\M} 3 } } */
