[llvm-bugs] [Bug 33695] New: InstCombine does invalid transformation

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 5 17:41:37 PDT 2017


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: unassignedbugs at nondot.org
          Reporter: babokin at gmail.com
                CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170706/62ea7e56/attachment.html>


More information about the llvm-bugs mailing list