[llvm-bugs] [Bug 43420] New: __builtin_constant_p resolves differently with loop unrolling at -O3

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 23 16:16:40 PDT 2019


            Bug ID: 43420
           Summary: __builtin_constant_p resolves differently with loop
                    unrolling at -O3
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: ndesaulniers at google.com
                CC: isanbard at gmail.com, jyknight at google.com,
                    llvm-bugs at lists.llvm.org, srhines at google.com
            Blocks: 4068

void c(void);

void a(void) {
  for (int b = 0x10; b; b <<= 1)
    if (__builtin_constant_p(b))

Clang at -O2 and GCC at -O3 look similar.  At -O3, LLVM unrolls the loop 27
times, but b is no longer an ICE or rather BCP evaluates to false.  This
triggers a miscompile (__bad_udelay is purposely undefined) in the Linux kernel
at -O3.


Referenced Bugs:

[Bug 4068] [Meta] Compiling the Linux kernel with clang
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/20190923/926565d8/attachment.html>

More information about the llvm-bugs mailing list