saqut-compiler/tests/golden/opt/run_opt.sqt

32 lines
832 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Optimize edilmiş çalıştırmanın doğruluğunu kanıtlayan golden test.
//
// Tetiklenen optimizasyonlar:
// - Constant folding: 100 - 6*15 + 4, 3*3 + 4*4 derleme zamanında hesaplanır
// - DCE: return sonrası print(999) ve print(888) silinir
// - Folding zincirleme: iç fonksiyon çağrısı olmaksızın tüm sabit ifadeler katlanır
//
// saqut run ve saqut run --optimized AYNI çıktıyı vermeli.
// Eğer optimizasyon bir değeri yanlış katlarsa veya canlı kodu silerse bu test kırılır.
int compute() {
int result = 100 - 6 * 15 + 4;
return result;
print(999);
}
int classify(int n) {
if (n > 0) {
return 1;
print(888);
}
return 0;
}
int main() {
print(compute());
print(classify(5));
print(classify(-3));
print(3 * 3 + 4 * 4);
return 0;
}