xref: /aosp_15_r20/external/clang/test/CodeGen/pgo-sample-preparation.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // Test if PGO sample use preparation passes are executed correctly.
2*67e74705SXin Li //
3*67e74705SXin Li // Ensure that instcombine is executed after simplifycfg and sroa so that
4*67e74705SXin Li // "a < 255" will not be converted to a * 256 < 255 * 256.
5*67e74705SXin Li // RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -emit-llvm -o - 2>&1 | FileCheck %s
6*67e74705SXin Li 
7*67e74705SXin Li void bar(int);
foo(int x,int y,int z)8*67e74705SXin Li void foo(int x, int y, int z) {
9*67e74705SXin Li   int m;
10*67e74705SXin Li   for (m = 0; m < x ; m++) {
11*67e74705SXin Li     int a = (((y >> 8) & 0xff) * z) / 256;
12*67e74705SXin Li     bar(a < 255 ? a : 255);
13*67e74705SXin Li   }
14*67e74705SXin Li }
15*67e74705SXin Li 
16*67e74705SXin Li // CHECK-NOT: icmp slt i32 %mul, 65280
17