Bug 53347 - Duplicated redundant condition in compare-elim.c
Duplicated redundant condition in compare-elim.c
Status: UNCONFIRMED
Product: gcc
Classification: Unclassified
Component: middle-end
4.8.0
: P3 trivial
: ---
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-14 15:44 UTC by Paulo J. Matos
Modified: 2012-05-15 09:56 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paulo J. Matos 2012-05-14 15:44:09 UTC
There's a duplicated redundant condition in compare-elim.c, line 148:
  if (REG_P (XEXP (src, 0))
      && REG_P (XEXP (src, 0))
      && (REG_P (XEXP (src, 1)) || CONSTANT_P (XEXP (src, 1))))
    return src;

This can be simplified:
  if (REG_P (XEXP (src, 0))
      && (REG_P (XEXP (src, 1)) || CONSTANT_P (XEXP (src, 1))))
    return src;

I think care must be taken to ensure that this is indeed duplicated and that the developer didn't intend to write something else instead.
Comment 1 Paolo Bonzini 2012-05-15 09:56:59 UTC
The code in conforming_compare matches this comment with or without the duplicate test:

   (1) All comparison patterns are represented as

	[(set (reg:CC) (compare:CC (reg) (immediate)))]

so it looks like it could be removed.