public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/46679] New: fold_binary changes types in divisionm breaking configure -enable-checking
@ 2010-11-27  1:09 jay.krell at cornell dot edu
  2010-12-02  9:09 ` [Bug middle-end/46679] " jay.krell at cornell dot edu
  2024-04-02 22:25 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: jay.krell at cornell dot edu @ 2010-11-27  1:09 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46679

           Summary: fold_binary changes types in divisionm breaking
                    configure -enable-checking
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jay.krell@cornell.edu


fold_binary seemingly changes the types of division inputs (but not the
output),
leading to configure -enable-checking to fail.


My code is something like this (using a different frontend
and slightly patched 4.5.1 but I don't think relevantly):


long a;

long F(void)
{
 return a / a;
}

configure -enable-checking=fold,...:

gcc-4.5
fold-const.c

fold_binary_loc(code = FLOOR_DIV_EXPR,
                op0, op1, type all int_64


arg0, arg1 become word_64
(not op0, op1, but arg0, arg1)


and then we end up here:

      if ((code == CEIL_DIV_EXPR || code == FLOOR_DIV_EXPR)
      && multiple_of_p (type, arg0, arg1))
    return fold_build2_loc (loc, EXACT_DIV_EXPR, type, arg0, arg1);


and then:


error: type mismatch in binary expression
int_64
word_64
word_64


D.1003 = D.1001 /[ex] D.1002;


multiple_of_p is true because the operands are the same.
 (This would optimize to 1, unless the operands might be 0.)


I'll see if I can reproduce with unpatched C 4.5.1 and trunk.


 - Jay


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug middle-end/46679] fold_binary changes types in divisionm breaking configure -enable-checking
  2010-11-27  1:09 [Bug middle-end/46679] New: fold_binary changes types in divisionm breaking configure -enable-checking jay.krell at cornell dot edu
@ 2010-12-02  9:09 ` jay.krell at cornell dot edu
  2024-04-02 22:25 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jay.krell at cornell dot edu @ 2010-12-02  9:09 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46679

Jay <jay.krell at cornell dot edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|4.5.1                       |4.6.0

--- Comment #1 from Jay <jay.krell at cornell dot edu> 2010-12-02 09:08:49 UTC ---
You can "prove", almost, the existance of the bug by
making this change to slightly increase it:

jbook2:gcc jay$ svn diff  fold-const.c 
Index: fold-const.c
===================================================================
--- fold-const.c    (revision 167194)
+++ fold-const.c    (working copy)
@@ -11648,7 +11648,7 @@
      Note that only CEIL_DIV_EXPR and FLOOR_DIV_EXPR are rewritten now.
      At one time others generated faster code, it's not clear if they do
      after the last round to changes to the DIV code in expmed.c.  */
-      if ((code == CEIL_DIV_EXPR || code == FLOOR_DIV_EXPR)
+      if ((code == CEIL_DIV_EXPR || code == TRUNC_DIV_EXPR || code ==
FLOOR_DIV_EXPR)
       && multiple_of_p (type, arg0, arg1))
     return fold_build2_loc (loc, EXACT_DIV_EXPR, type, arg0, arg1);


it: I don't think C ever produces ceil_div/floor_div, so
it's hard to demonstrate.

With this, bootstrap fails:


/src/gcc-trunk/configure -prefix=/usr/local/gcc-trunk
-enable-checking=assert,df,fold,misc,rtl,rtlflag,runtime,tree,types && make -j4

/src/gcc-trunk/gcc/tree-ssa-loop-prefetch.c:1503:1: error: type mismatch in
binary expression
unsigned int
int
unsigned int
D.55547 = D.55546 /[ex] 16;

other than just removing this chunk of code completely,
I might suggest checking that arg0 == op0 && arg1 == op1.
Though that is probably a bit more conservative than necessary.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug middle-end/46679] fold_binary changes types in divisionm breaking configure -enable-checking
  2010-11-27  1:09 [Bug middle-end/46679] New: fold_binary changes types in divisionm breaking configure -enable-checking jay.krell at cornell dot edu
  2010-12-02  9:09 ` [Bug middle-end/46679] " jay.krell at cornell dot edu
@ 2024-04-02 22:25 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-02 22:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46679

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Already fixed; dup.

*** This bug has been marked as a duplicate of bug 66984 ***

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-02 22:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-27  1:09 [Bug middle-end/46679] New: fold_binary changes types in divisionm breaking configure -enable-checking jay.krell at cornell dot edu
2010-12-02  9:09 ` [Bug middle-end/46679] " jay.krell at cornell dot edu
2024-04-02 22:25 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).