Hi Nikita,

> While investigating Zicond extension code generation on RISC-V, I identified
> several cases where GCC (trunk) generates suboptimal code due to premature 
> if-conversion.
>
> Consider the following test case:
> CFLAGS: -march=rv64gc_zicond -mabi=lp64d -O2
>
> int test_IOR_ceqz_x (int x, int z, int c)
> {
>   if (c)
>     x = x | z;
>   return x;
> }
>
> Before the patch:
>   or      a1,a0,a1
>   czero.eqz a1,a1,a2
>   czero.nez a0,a0,a2
>   add     a0,a0,a1
>   ret
>
> The issue occurs when ifcvt encounters the following RTL pattern:
>   (set reg1 (ior:DI (reg2:DI) (reg3:DI)))
>   (set reg4 (sign_extend:DI (subreg:SI (reg1:DI))))
>
> When reg1 is no longer used, this expression could be simplified. However,
> noce_convert_multiple_sets converts the block early, preventing combine from
> optimizing the pattern.

yes, that looks not ideal indeed.  I wonder if checking for sign_extension is 
not too specific and we'd rather want something like
"is the single use of the current SET_DEST inside the BB we transform"?

That probably has unintended consequences as well, though...

-- 
Regards
 Robin

Reply via email to