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]

How can I get VRP information for an RTX?


I am looking at how the MIPS backend handles division. For the compiler configuration in question (mipsel-linux) division operations trap on division by zero. This is handled in mips_output_division in mips.c where we unconditionally emit a conditional trap.

I would like to change it so that if the divisor is not zero, the conditional trap would be omitted. I am looking at this small test program:

int divtest(int x, int y)
{
   if (y == 0)
       return 45;
   else
       return x / y;
}

If I set a breakpoint in mips_output_division, I can print out the operands for the division operation:
(gdb) p operands[2]
$6 = (rtx) 0x2aaaae155aa0
(gdb) pr
(reg/v:SI 5 $5 [orig:196 y ] [196])


Q1: Is it possible to get to the VRP information from this rtx? How?

If the VRP information is available, it would be nice to |define_expand for the division/conditional trap and perhaps let the compiler schedule the trap. However the define_expand documentation states that the condition for the define_expand cannot depend on the data in the insn being matched. That would seem to imply that the expansion cannot be dependent on the VRP information.

Q2: Is that correct, and why?

Q3: Would it be better to do this at the tree level instead of rtl?


Thanks in advance, David Daney |



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