diff -urN libpfm-3.0/ChangeLog libpfm-3.0a/ChangeLog
--- libpfm-3.0/ChangeLog	2003-11-26 14:25:22.000000000 -0800
+++ libpfm-3.0a/ChangeLog	2004-02-13 18:26:21.401929135 -0800
@@ -1,3 +1,9 @@
+2004-02-12 Stephane Eranian <eranian@hpl.hp.com>
+	* fixed a bug in pfmlib_itanium2.c which cause measurements
+	  using opcode matching with an event different from
+	  IA64_TAGGED_INST_RETIRED* to return wrong results, i.e.,
+	  opcode filter was ignored.
+
 2003-11-21 Stephane Eranian <eranian@hpl.hp.com>
 	* changed interface to pfm_get_impl_*() to use
 	  a cleaner definition for bitmasks. pfmlib_regmask_t is
diff -urN libpfm-3.0/lib/pfmlib_itanium2.c libpfm-3.0a/lib/pfmlib_itanium2.c
--- libpfm-3.0/lib/pfmlib_itanium2.c	2003-11-26 14:22:36.000000000 -0800
+++ libpfm-3.0a/lib/pfmlib_itanium2.c	2004-02-12 18:03:24.575727041 -0800
@@ -1471,7 +1471,7 @@
 	pfm_ita2_pmc_reg_t pmc13;
 	pfm_ita2_pmc_reg_t pmc14;
 	unsigned int i, pos = outp->pfp_pmc_count;
-	int iod_codes[4], dfl_val;
+	int iod_codes[4], dfl_val_pmc8, dfl_val_pmc9;
 	unsigned int n_intervals;
 	int ret;
 	int base_idx = 0;
@@ -1505,7 +1505,8 @@
 	 * if drange is used we do not know in advance which DBR will be used
 	 * therefore we need to apply dfl_val later
 	 */
-	dfl_val = param->pfp_ita2_pmc8.opcm_used || param->pfp_ita2_pmc9.opcm_used ? OP_USED : 0;
+	dfl_val_pmc8 = param->pfp_ita2_pmc8.opcm_used ? OP_USED : 0;
+	dfl_val_pmc9 = param->pfp_ita2_pmc9.opcm_used ? OP_USED : 0;
 
 	if (param->pfp_ita2_drange.rr_used == 1) {
 
@@ -1528,10 +1529,10 @@
 		 * Update iod_codes to reflect the use of the DBR constraint.
 		 */
 		for (i=0; i < orr->rr_nbr_used; i++) {
-			if (orr->rr_br[i].reg_num == 0) iod_codes[0] |= DR_USED | dfl_val;
-			if (orr->rr_br[i].reg_num == 2) iod_codes[1] |= DR_USED | dfl_val;
-			if (orr->rr_br[i].reg_num == 4) iod_codes[2] |= DR_USED | dfl_val;
-			if (orr->rr_br[i].reg_num == 6) iod_codes[3] |= DR_USED | dfl_val;
+			if (orr->rr_br[i].reg_num == 0) iod_codes[0] |= DR_USED | dfl_val_pmc8;
+			if (orr->rr_br[i].reg_num == 2) iod_codes[1] |= DR_USED | dfl_val_pmc9;
+			if (orr->rr_br[i].reg_num == 4) iod_codes[2] |= DR_USED | dfl_val_pmc8;
+			if (orr->rr_br[i].reg_num == 6) iod_codes[3] |= DR_USED | dfl_val_pmc9;
 		}
 
 	}
@@ -1565,13 +1566,18 @@
 		 * Update to reflect the use of the IBR constraint
 		 */
 		for (i=0; i < orr2->rr_nbr_used; i++) {
-			if (orr2->rr_br[i].reg_num == 0) iod_codes[0] |= IR_USED | dfl_val;
-			if (orr2->rr_br[i].reg_num == 2) iod_codes[1] |= IR_USED | dfl_val;
-			if (fine_mode == 0 && orr2->rr_br[i].reg_num == 4) iod_codes[2] |= IR_USED | dfl_val;
-			if (fine_mode == 0 && orr2->rr_br[i].reg_num == 6) iod_codes[3] |= IR_USED | dfl_val;
+			if (orr2->rr_br[i].reg_num == 0) iod_codes[0] |= IR_USED | dfl_val_pmc8;
+			if (orr2->rr_br[i].reg_num == 2) iod_codes[1] |= IR_USED | dfl_val_pmc9;
+			if (fine_mode == 0 && orr2->rr_br[i].reg_num == 4) iod_codes[2] |= IR_USED | dfl_val_pmc8;
+			if (fine_mode == 0 && orr2->rr_br[i].reg_num == 6) iod_codes[3] |= IR_USED | dfl_val_pmc9;
 		}
 	}
 
+	if (param->pfp_ita2_irange.rr_used == 0 && param->pfp_ita2_drange.rr_used ==0) {
+		iod_codes[0] = iod_codes[2] = dfl_val_pmc8;
+		iod_codes[1] = iod_codes[3] = dfl_val_pmc9;
+	}
+
 	/*
 	 * update the cfg dbrpX field. If we put a constraint on a cfg dbrp, then
 	 * we must enable it in the corresponding ena_dbrpX
