[llvm-bugs] [Bug 27575] New: miscompile of select at O1

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 29 10:08:39 PDT 2016


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

            Bug ID: 27575
           Summary: miscompile of select at O1
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: kcc at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

#include <stdio.h>
int main(int argc, char **argv) {
  int i = argc - 1;
  int a = 1 << i;
  int b = a >> 1;
  double c = b > 0 ? (double)b : 0.5;
  printf("%d %g\n", b, c);
}


for f in 0 1 2; do clang++  -O$f  bug.cc && ./a.out ; done
0 0.5
0 0
0 0


This is what I see in IR: 

*** IR Dump After Dead Argument Elimination ***; ModuleID = 'bug.cc'
  %cond = select i1 %cmp, double %conv, double 5.000000e-01

*** IR Dump After Combine redundant instructions ***
  %1 = select i1 %0, i32 %shr, i32 0


I don't see how this transformation could be legal.

-- 
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/20160429/853dd57e/attachment.html>


More information about the llvm-bugs mailing list