[llvm-bugs] [Bug 49005] New: [ConstantFold] WRONG code after 53040a9 "Fold more operations to poison"

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Feb 2 15:34:22 PST 2021


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

            Bug ID: 49005
           Summary: [ConstantFold] WRONG code after 53040a9 "Fold more
                    operations to poison"
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: paulsson at linux.vnet.ibm.com
                CC: llvm-bugs at lists.llvm.org

This program:

unsigned int a = 0, b = 0;
unsigned char c(unsigned char d, unsigned char e) { return d + e; }
int main() {
  char f = 0;
  unsigned int *g = &b;
  for (a = 7; a != 5; a = c(a, 6)) {  // a=7..OF..a=3..OF..a=5
    f = a >= 8 ? 1 : 5 >> a;   // f = 1 just before a = 5
    *g = (f & 4) <= 0;         // *g = 1
  }
  printf("%d\n", b);
}

should print '1' for the value of 'b', but it currently prints '0'.

A bisect indicated this to be due to 53040a9:

*** IR Dump After Global Value Number   *** IR Dump After Global Value Number
; Function Attrs: nofree nounwind       ; Function Attrs: nofree nounwind
define dso_local signext i32 @main()    define dso_local signext i32 @main() 
entry:                                  entry:
  store i32 7, i32* @a, align 4, !tba     store i32 7, i32* @a, align 4, !tba
  store i32 1, i32* @b, align 4, !tba |   store i32 poison, i32* @b, align 4,
  store i32 5, i32* @a, align 4, !tba     store i32 5, i32* @a, align 4, !tba
  %call7 = tail call signext i32 (i8* |   %call7 = tail call signext i32 (i8*
  ret i32 0                               ret i32 0
}                                       }

The '1' has now become a poison value, which seems incorrect...

./bin/clang -march=z10 -O2

-- 
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/20210202/dcf08e9a/attachment.html>


More information about the llvm-bugs mailing list