<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ConstantFold] WRONG code after 53040a9 "Fold more operations to poison""
   href="https://bugs.llvm.org/show_bug.cgi?id=49005">49005</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[ConstantFold] WRONG code after 53040a9 "Fold more operations to poison"
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>paulsson@linux.vnet.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>