This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RTL Expand pass - Difference in float and int datatypes


Anitha Boyapati <anitha.boyapati@gmail.com> writes:

> int main() {
> ÂÂÂÂÂÂÂ volatile int a, b;
> ÂÂÂÂÂÂÂ if(a>b) return 1;
> ÂÂÂÂÂÂÂ else return 2;
>
> }
>
> Expand  pass shows that "le"operator  is chosen.
>
> (jump_insn 9 8 10 3 gt_int.c:4 (set (pc)
>         (if_then_else (le:CC (cc0)
>                 (const_int 0 [0x0]))
>             (label_ref 14)
>             (pc))) -1 (nil))
>
>
> If I modify the same testcase to use 'float' datatype instead of
> 'int', "gt" operator is picked up.
>
> (jump_insn 9 8 34 3 gt.c:4 (set (pc)
>         (if_then_else (gt:CC (cc0)
>                 (const_int 0 [0x0]))
>             (label_ref 12)
>             (pc))) -1 (nil))
>
>
> I would like to know what prompts gcc to decide if "le" can be used in
> the expand pass rather than "gt" operator. Or more precisely why it
> differs incase of float.

The choice of LE when using int is just a happenstance of the way that
gcc generates code.  When gcc comes to RTL generation it happens to be
looking at an if statement that falls through on true and branches on
else.  So it flips the condition to branch on true (in
do_compare_rtx_and_jump).  The use of volatile doesn't affect this: it
will still only load the variables precisely as described in the
program.

The condition can not be flipped for float because that would be an
invalid transformation if one of the values is NaN.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]