Bug 53347 - Duplicated redundant condition in compare-elim.c
Summary: Duplicated redundant condition in compare-elim.c
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.8.0
: P3 trivial
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-14 15:44 UTC by Paulo J. Matos
Modified: 2017-12-11 17:43 UTC (History)
2 users (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.
Comment 2 Jeffrey A. Law 2017-12-11 17:43:53 UTC
Eric fixed this as part of the compare-elim revamp last year.