https://bugs.llvm.org/show_bug.cgi?id=33695

            Bug ID: 33695
           Summary: InstCombine does invalid transformation
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: babo...@gmail.com
                CC: llvm-bugs@lists.llvm.org

clang trunk (also reproducible with 4.0, not reproducible with 3.9), x86_64.

> cat f.cpp
#include <stdio.h>

unsigned char uc = 170;
unsigned char var_1 = 252;
unsigned int var_33 = 1346838541U;
unsigned char var_36;
void foo() {
  var_36 = (((var_33 | (0xaf2597a4 | uc)) << 26) - var_1) * 70983U;
}

int main() {
  foo();
  printf("result: %d\n", var_36);
  return 0;
}

> clang++ -O0 f.cpp -o out0
> ./out0
result: 28

> clang++ -O2 f.cpp -o out2
> ./out2
result: 0

Opt-bisect points to "Combine redundant instructions on function", which
removes the calculations and foo() and stores 0 to var_36, which is incorrect
value.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to