Hi, all I do the research of min max instructions recently. I find it is related with phiopt.
case1: int foo(short a ,short b) { if (a < b) a = b; return a; } It is successed in pass phiopt1(-O2 with gcc 4.7.0). The MAX_EXPR can be generated. foo (short int a, short int b) { int D.2094; <bb 2>: a_9 = MAX_EXPR <a_2(D), b_3(D)>; D.2094_5 = (int) a_9; return D.2094_5; } But when I do the test for a case with a little change, it is failed to generate MAX_EXPR in phiopt1. The failed case2 : int foo(short a ,short b) { int c; if (a < b) a = b; c = *(int *)&a; return c; } I find it is because of the esra pass failed to generate PHI NODE. Dump of phifail.c.027t.esra: foo (short int a, short int b) { int c; short int a$0; <bb 2>: a$0_1 = a; if (a$0_1 < b_2(D)) goto <bb 3>; else goto <bb 4>; <bb 3>: a = b_2(D); <bb 4>: c_4 = MEM[(int *)&a]; c_5 = c_4; return c_5; } Why it is failed and if there's a way to make it work? Please give some help, thanks. Yang Yueming.