[LLVMbugs] [Bug 2330] New: Misc missed instcombines

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu May 15 12:43:48 PDT 2008


http://llvm.org/bugs/show_bug.cgi?id=2330

           Summary: Misc missed instcombines
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sharparrow1 at yahoo.com
                CC: llvmbugs at cs.uiuc.edu


Not sure it's really worthwhile to file a bug for each of these, so I guess
I'll collect them here, and then decide what to do with them.  Should I file
separate bugs instead?

>From GCC Bug 31261:
int a(int a) {return (8 - a) & 7;}
The "8 - a" should be simplified to "-a".

>From GCC Bug 24696:
int
f (unsigned long a, unsigned long b, unsigned long c)
{
  return ((a & (c - 1)) != 0) || ((b & (c - 1)) != 0);
}
The two icmps should be combined.

>From GCC Bug 20192:
#define PMD_MASK    (~((1UL << 23) - 1))
void clear_pmd_range(unsigned long start, unsigned long end) 
{ 
    if (!(start & ~PMD_MASK) && !(end & ~PMD_MASK)) 
        f(); 
}
The two icmps should be combined.

>From GCC Bug 15350:
void bar (void);
void
foo (int a)
{
  if ((1 << a) & 1)
    bar ();
}
Should be combined to a != 0.

>From GCC Bug 15241:
unsigned int
foo (unsigned int a, unsigned int b)
{
  if (a <= 7 && b <= 7)
    baz ();
}
Should combine to "(a|b) <= 7".

>From GCC Bug 3756:
int
pn (int n)
{
  return (n >= 0 ? 1 : -1);
}
Should combine to (n >> 31) | 1.

>From GCC Bug 28685:
int test(int a, int b)
{
  int lt = a < b;
  int eq = a == b;

  return (lt || eq);
}
Should combine to "a <= b".


void a(int variable)
{
  if (variable == 4 || variable == 6)
    bar();
}
This should optimize to "if ((variable | 2) == 6)".


unsigned int f(unsigned int i, unsigned int n) {++i; if (i == n) ++i; return
i;}
unsigned int f2(unsigned int i, unsigned int n) {++i; i += i == n; return i;}
These should combine to the same thing.

>From GCC Bug 33512:
int f(int y, int x)
{
  return x & ((~x) | y);
}
Should combine to x & y.

>From GCC Bug 31096:
int f(int a, int b)
{
  return a * 10 == b * 10;
}
This can be optimized to a & 0x7FFFFFFF == b & 0x7FFFFFFF.

>From GCC Bug 15784:
#define abs(x) x>0?x:-x
int f(int x, int y)
{
  return (abs(x)) >= 0;
}
This should optimize to x == INT_MIN. (With -fwrapv.)

>From GCC Bug 14753:
void
rotate_cst (unsigned int a)
{
  a = (a << 10) | (a >> 22);
  if (a == 123)
    bar ();
}
void
minus_cst (unsigned int a)
{
  unsigned int tem;

  tem = 20 - a;
  if (tem == 5)
    bar ();
}
void
mask_gt (unsigned int a)
{
  /* This is equivalent to a > 15.  */
  if ((a & ~7) > 8)
    bar ();
}
void
rshift_gt (unsigned int a)
{
  /* This is equivalent to a > 23.  */
  if ((a >> 2) > 5)
    bar ();
}
All should simplify to a single comparison.

>From GCC Bug 32605:
int c(int* x) {return (char*)x+2 == (char*)x;}
Should combine to 0.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list