[PATCH] D24593: Standford/Bubble sort code restructure

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 14 17:18:13 PDT 2016


MatzeB added inline comments.

================
Comment at: SingleSource/Benchmarks/Stanford/Bubblesort.c:134
@@ -133,1 +133,3 @@
+	biggest = sortlist[1]; littlest = sortlist[1];
+	for ( i = 2; i <= srtelements; i++ ) {
 	    temp = Rand();
----------------
evstupac wrote:
> mehdi_amini wrote:
> > I don't understand why this change? (i.e. it should be at least documented).
> Ok. We can skip this. Yes this one is just peeling and set MAX (biggest) and MIN (littlest) to sortlist element. Otherwise it could happen that  MAX (biggest) and/or MIN (littlest) will stay 0 after the Init loop.
> That is just potential bug if we change array length or rand algorithm. In the test we have sortlist elements that are bigger and less than 0.
If srtelements is 0, then we will write to sortlist[1] with this change which is bad.

================
Comment at: SingleSource/Benchmarks/Stanford/Bubblesort.c:160
@@ -156,1 +159,3 @@
+			sortlist[i] = sli;
+			sortlist[i + 1] = sli1;
 			i=i+1;
----------------
mehdi_amini wrote:
> evstupac wrote:
> > The flakiness is here. And the change allows to avoid the flakiness.
> Please define "flakiness".
I don't understand, the code does the same thing before and after. (You just change to always read and write the array elements even in the case where no swap happens).


https://reviews.llvm.org/D24593





More information about the llvm-commits mailing list