Reviewed By: mbouaziz Differential Revision: D10288095 fbshipit-source-id: 55cd2870amaster
parent
affe3d1d60
commit
8a51a70162
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class HoistNoIndirectMod {
|
||||||
|
|
||||||
|
int id = 0;
|
||||||
|
|
||||||
|
public int increment() {
|
||||||
|
id = calcNext();
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int calcNext() {
|
||||||
|
return (id + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int calcSame() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int increment_dont_hoist_FP(int n) {
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
id = calcNext(); // shouldn't be hoisted
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int modify_and_increment_dont_hoist_FP(int n) {
|
||||||
|
int p = 0;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
p += calcNext();
|
||||||
|
id = i;
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue