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: unassignedb...@nondot.org
          Reporter: k...@google.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to