[llvm-bugs] [Bug 34037] New: InstCombine - invalid transformation

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 2 15:50:58 PDT 2017


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

            Bug ID: 34037
           Summary: InstCombine - invalid transformation
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: babokin at gmail.com
                CC: llvm-bugs at lists.llvm.org

clang trunk, rev 309831, x86_64.

Valid, UB-free test case, -O2 produce different output. 

Opt-bisect points to InstCombine.


> cat f.cpp
#include <stdio.h>
long j = 0, p = 0;
unsigned k = 4, r = 0;
unsigned long m = 0;
static long cc = 0;
static unsigned short dd = 0;;
void fn1() {
  long a = (~(m & r) | j) << 29;
  cc = ((a - dd) * k) & (unsigned short)p;
}
int main() {
  p = dd = 7;
  fn1();
  printf("%ld\n", cc);
}

> clang -O0 f.cpp -o out; ./out
4

> clang -O2 f.cpp -o out; ./out
0

-- 
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/20170802/c4d4bd0b/attachment.html>


More information about the llvm-bugs mailing list