From c987a727a76eda1feada07e2eca6a5597dbddd93 Mon Sep 17 00:00:00 2001 From: Alex Brachet Date: Tue, 19 Jul 2022 19:54:04 +0000 Subject: [PATCH] nir: Fix qsort comparator function `pred` is a pointer, for sufficiently large numbers these being cast to int were both > 0 regardless of the order of `data1` and `data2`. Fixes: 523a28d3fe0d ("nir: add an instruction set API") Reviewed-by: Jason Ekstrand Part-of: --- src/compiler/nir/nir_instr_set.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c index 9ce5793594e..032fcbcb918 100644 --- a/src/compiler/nir/nir_instr_set.c +++ b/src/compiler/nir/nir_instr_set.c @@ -212,7 +212,7 @@ cmp_phi_src(const void *data1, const void *data2) { nir_phi_src *src1 = *(nir_phi_src **)data1; nir_phi_src *src2 = *(nir_phi_src **)data2; - return src1->pred - src2->pred; + return src1->pred > src2->pred ? 1 : (src1->pred == src2->pred ? 0 : -1); } static uint32_t