Thanks, taking a look.<br><br>On Friday, April 22, 2016, Mikael Holmén <<a href="mailto:mikael.holmen@ericsson.com">mikael.holmen@ericsson.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Same thing is happening to me.<br>
<br>
 Transforms/EarlyCSE/basic.ll<br>
<br>
is failing quite randomly now and then with:<br>
<br>
Command Output (stderr):<br>
--<br>
/repo/uabelho/dev-master/test/Transforms/EarlyCSE/basic.ll:31:16: error: expected string not found in input<br>
 ; CHECK-NEXT: %G = add nuw i32 %C, %C<br>
               ^<br>
<stdin>:14:23: note: scanning from here<br>
 store volatile i32 %E, i32* %P<br>
                      ^<br>
<stdin>:15:3: note: possible intended match here<br>
 store volatile i32 %E, i32* %P<br>
  ^<br>
<br>
Regards,<br>
Mikael<br>
<br>
On 04/22/2016 03:22 PM, Daniel Sanders via llvm-commits wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Resent to the correct mailing list. Outlook makes me re-add the list on every reply and I didn't notice I'd autocompleted to the wrong one.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-----Original Message-----<br>
From: llvm-dev [mailto:<a>llvm-dev-bounces@lists.llvm.org</a>] On Behalf Of Daniel<br>
Sanders via llvm-dev<br>
Sent: 22 April 2016 11:36<br>
To: David Majnemer; <a>llvm-dev@lists.llvm.org</a><br>
Subject: Re: [llvm-dev] [llvm] r267111 - [EarlyCSE] Take the intersection of<br>
flags on instructions<br>
<br>
Hi David,<br>
<br>
When I reverted r267098 in r267127, one of the EarlyCSE tests failed on a<br>
couple builders (<a href="http://lab.llvm.org:8011/builders/llvm-hexagon-" target="_blank">http://lab.llvm.org:8011/builders/llvm-hexagon-</a><br>
elf/builds/28174, <a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-" target="_blank">http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-</a><br>
scei-ps4-ubuntu-fast/builds/11173). Going by the logs it was CSE'ing two adds<br>
where one had the nuw flag and one didn't. The failures disappeared by<br>
themselves in the next build but I thought I should mention it anyway.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-----Original Message-----<br>
From: llvm-commits [mailto:<a>llvm-commits-bounces@lists.llvm.org</a>] On<br>
</blockquote>
Behalf<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Of David Majnemer via llvm-commits<br>
Sent: 22 April 2016 07:38<br>
To: <a>llvm-commits@lists.llvm.org</a><br>
Subject: [llvm] r267111 - [EarlyCSE] Take the intersection of flags on<br>
instructions<br>
<br>
Author: majnemer<br>
Date: Fri Apr 22 01:37:45 2016<br>
New Revision: 267111<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=267111&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=267111&view=rev</a><br>
Log:<br>
[EarlyCSE] Take the intersection of flags on instructions<br>
<br>
EarlyCSE had inconsistent behavior with regards to flag'd instructions:<br>
- In some cases, it would pessimize if the available instruction had<br>
   different flags by not performing CSE.<br>
- In other cases, it would miscompile if it replaced an instruction<br>
   which had no flags with an instruction which has flags.<br>
<br>
Fix this by being more consistent with our flag handling by utilizing<br>
andIRFlags.<br>
<br>
Added:<br>
     llvm/trunk/test/Transforms/EarlyCSE/flags.ll<br>
Modified:<br>
     llvm/trunk/include/llvm/IR/InstrTypes.h<br>
     llvm/trunk/include/llvm/IR/Instruction.h<br>
     llvm/trunk/include/llvm/IR/Operator.h<br>
     llvm/trunk/lib/IR/Instruction.cpp<br>
     llvm/trunk/lib/IR/Instructions.cpp<br>
     llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/IR/InstrTypes.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
<br>
</blockquote>
project/llvm/trunk/include/llvm/IR/InstrTypes.h?rev=267111&r1=267110&r2<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
=267111&view=diff<br>
<br>
</blockquote>
==========================================================<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
====================<br>
--- llvm/trunk/include/llvm/IR/InstrTypes.h (original)<br>
+++ llvm/trunk/include/llvm/IR/InstrTypes.h Fri Apr 22 01:37:45 2016<br>
@@ -535,35 +535,6 @@ public:<br>
    ///<br>
    bool swapOperands();<br>
<br>
-  /// Set or clear the nsw flag on this instruction, which must be an<br>
</blockquote>
operator<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-  /// which supports this flag. See LangRef.html for the meaning of this<br>
</blockquote>
flag.<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-  void setHasNoUnsignedWrap(bool b = true);<br>
-<br>
-  /// Set or clear the nsw flag on this instruction, which must be an<br>
</blockquote>
operator<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-  /// which supports this flag. See LangRef.html for the meaning of this<br>
</blockquote>
flag.<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-  void setHasNoSignedWrap(bool b = true);<br>
-<br>
-  /// Set or clear the exact flag on this instruction, which must be an<br>
</blockquote>
operator<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-  /// which supports this flag. See LangRef.html for the meaning of this<br>
</blockquote>
flag.<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-  void setIsExact(bool b = true);<br>
-<br>
-  /// Determine whether the no unsigned wrap flag is set.<br>
-  bool hasNoUnsignedWrap() const;<br>
-<br>
-  /// Determine whether the no signed wrap flag is set.<br>
-  bool hasNoSignedWrap() const;<br>
-<br>
-  /// Determine whether the exact flag is set.<br>
-  bool isExact() const;<br>
-<br>
-  /// Convenience method to copy supported wrapping, exact, and fast-<br>
math flags<br>
-  /// from V to this instruction.<br>
-  void copyIRFlags(const Value *V);<br>
-<br>
-  /// Logical 'and' of any supported wrapping, exact, and fast-math flags of<br>
-  /// V and this instruction.<br>
-  void andIRFlags(const Value *V);<br>
-<br>
    // Methods for support type inquiry through isa, cast, and dyn_cast:<br>
    static inline bool classof(const Instruction *I) {<br>
      return I->isBinaryOp();<br>
<br>
Modified: llvm/trunk/include/llvm/IR/Instruction.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
<br>
</blockquote>
project/llvm/trunk/include/llvm/IR/Instruction.h?rev=267111&r1=267110&r2<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
=267111&view=diff<br>
<br>
</blockquote>
==========================================================<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
====================<br>
--- llvm/trunk/include/llvm/IR/Instruction.h (original)<br>
+++ llvm/trunk/include/llvm/IR/Instruction.h Fri Apr 22 01:37:45 2016<br>
@@ -223,6 +223,27 @@ public:<br>
    /// Return the debug location for this node as a DebugLoc.<br>
    const DebugLoc &getDebugLoc() const { return DbgLoc; }<br>
<br>
+  /// Set or clear the nsw flag on this instruction, which must be an<br>
</blockquote>
operator<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  /// which supports this flag. See LangRef.html for the meaning of this<br>
</blockquote>
flag.<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  void setHasNoUnsignedWrap(bool b = true);<br>
+<br>
+  /// Set or clear the nsw flag on this instruction, which must be an<br>
</blockquote>
operator<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  /// which supports this flag. See LangRef.html for the meaning of this<br>
</blockquote>
flag.<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  void setHasNoSignedWrap(bool b = true);<br>
+<br>
+  /// Set or clear the exact flag on this instruction, which must be an<br>
operator<br>
+  /// which supports this flag. See LangRef.html for the meaning of this<br>
</blockquote>
flag.<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  void setIsExact(bool b = true);<br>
+<br>
+  /// Determine whether the no unsigned wrap flag is set.<br>
+  bool hasNoUnsignedWrap() const;<br>
+<br>
+  /// Determine whether the no signed wrap flag is set.<br>
+  bool hasNoSignedWrap() const;<br>
+<br>
+  /// Determine whether the exact flag is set.<br>
+  bool isExact() const;<br>
+<br>
    /// Set or clear the unsafe-algebra flag on this instruction, which must be<br>
</blockquote>
an<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    /// operator which supports this flag. See LangRef.html for the meaning<br>
</blockquote>
of<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    /// this flag.<br>
@@ -281,6 +302,14 @@ public:<br>
    /// Copy I's fast-math flags<br>
    void copyFastMathFlags(const Instruction *I);<br>
<br>
+  /// Convenience method to copy supported wrapping, exact, and fast-<br>
math flags<br>
+  /// from V to this instruction.<br>
+  void copyIRFlags(const Value *V);<br>
+<br>
+  /// Logical 'and' of any supported wrapping, exact, and fast-math flags of<br>
+  /// V and this instruction.<br>
+  void andIRFlags(const Value *V);<br>
+<br>
  private:<br>
    /// Return true if we have an entry in the on-the-side metadata hash.<br>
    bool hasMetadataHashEntry() const {<br>
<br>
Modified: llvm/trunk/include/llvm/IR/Operator.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
<br>
</blockquote>
project/llvm/trunk/include/llvm/IR/Operator.h?rev=267111&r1=267110&r2=<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
267111&view=diff<br>
<br>
</blockquote>
==========================================================<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
====================<br>
--- llvm/trunk/include/llvm/IR/Operator.h (original)<br>
+++ llvm/trunk/include/llvm/IR/Operator.h Fri Apr 22 01:37:45 2016<br>
@@ -79,7 +79,7 @@ public:<br>
    };<br>
<br>
  private:<br>
-  friend class BinaryOperator;<br>
+  friend class Instruction;<br>
    friend class ConstantExpr;<br>
    void setHasNoUnsignedWrap(bool B) {<br>
      SubclassOptionalData =<br>
@@ -130,7 +130,7 @@ public:<br>
    };<br>
<br>
  private:<br>
-  friend class BinaryOperator;<br>
+  friend class Instruction;<br>
    friend class ConstantExpr;<br>
    void setIsExact(bool B) {<br>
      SubclassOptionalData = (SubclassOptionalData & ~IsExact) | (B * IsExact);<br>
<br>
Modified: llvm/trunk/lib/IR/Instruction.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
<br>
</blockquote>
project/llvm/trunk/lib/IR/Instruction.cpp?rev=267111&r1=267110&r2=26711<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
1&view=diff<br>
<br>
</blockquote>
==========================================================<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
====================<br>
--- llvm/trunk/lib/IR/Instruction.cpp (original)<br>
+++ llvm/trunk/lib/IR/Instruction.cpp Fri Apr 22 01:37:45 2016<br>
@@ -96,6 +96,30 @@ void Instruction::moveBefore(Instruction<br>
        MovePos->getIterator(), getParent()->getInstList(), getIterator());<br>
  }<br>
<br>
+void Instruction::setHasNoUnsignedWrap(bool b) {<br>
+  cast<OverflowingBinaryOperator>(this)->setHasNoUnsignedWrap(b);<br>
+}<br>
+<br>
+void Instruction::setHasNoSignedWrap(bool b) {<br>
+  cast<OverflowingBinaryOperator>(this)->setHasNoSignedWrap(b);<br>
+}<br>
+<br>
+void Instruction::setIsExact(bool b) {<br>
+  cast<PossiblyExactOperator>(this)->setIsExact(b);<br>
+}<br>
+<br>
+bool Instruction::hasNoUnsignedWrap() const {<br>
+  return cast<OverflowingBinaryOperator>(this)->hasNoUnsignedWrap();<br>
+}<br>
+<br>
+bool Instruction::hasNoSignedWrap() const {<br>
+  return cast<OverflowingBinaryOperator>(this)->hasNoSignedWrap();<br>
+}<br>
+<br>
+bool Instruction::isExact() const {<br>
+  return cast<PossiblyExactOperator>(this)->isExact();<br>
+}<br>
+<br>
  /// Set or clear the unsafe-algebra flag on this instruction, which must be<br>
</blockquote>
an<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  /// operator which supports this flag. See LangRef.html for the meaning of<br>
this<br>
  /// flag.<br>
@@ -190,6 +214,37 @@ void Instruction::copyFastMathFlags(cons<br>
    copyFastMathFlags(I->getFastMathFlags());<br>
  }<br>
<br>
+void Instruction::copyIRFlags(const Value *V) {<br>
+  // Copy the wrapping flags.<br>
+  if (auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {<br>
+    setHasNoSignedWrap(OB->hasNoSignedWrap());<br>
+    setHasNoUnsignedWrap(OB->hasNoUnsignedWrap());<br>
+  }<br>
+<br>
+  // Copy the exact flag.<br>
+  if (auto *PE = dyn_cast<PossiblyExactOperator>(V))<br>
+    setIsExact(PE->isExact());<br>
+<br>
+  // Copy the fast-math flags.<br>
+  if (auto *FP = dyn_cast<FPMathOperator>(V))<br>
+    copyFastMathFlags(FP->getFastMathFlags());<br>
+}<br>
+<br>
+void Instruction::andIRFlags(const Value *V) {<br>
+  if (auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {<br>
+    setHasNoSignedWrap(hasNoSignedWrap() & OB-<br>
hasNoSignedWrap());<br>
+    setHasNoUnsignedWrap(hasNoUnsignedWrap() & OB-<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
hasNoUnsignedWrap());<br>
</blockquote>
+  }<br>
+<br>
+  if (auto *PE = dyn_cast<PossiblyExactOperator>(V))<br>
+    setIsExact(isExact() & PE->isExact());<br>
+<br>
+  if (auto *FP = dyn_cast<FPMathOperator>(V)) {<br>
+    FastMathFlags FM = getFastMathFlags();<br>
+    FM &= FP->getFastMathFlags();<br>
+    copyFastMathFlags(FM);<br>
+  }<br>
+}<br>
<br>
  const char *Instruction::getOpcodeName(unsigned OpCode) {<br>
    switch (OpCode) {<br>
<br>
Modified: llvm/trunk/lib/IR/Instructions.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
<br>
</blockquote>
project/llvm/trunk/lib/IR/Instructions.cpp?rev=267111&r1=267110&r2=26711<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
1&view=diff<br>
<br>
</blockquote>
==========================================================<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
====================<br>
--- llvm/trunk/lib/IR/Instructions.cpp (original)<br>
+++ llvm/trunk/lib/IR/Instructions.cpp Fri Apr 22 01:37:45 2016<br>
@@ -2201,62 +2201,6 @@ bool BinaryOperator::swapOperands() {<br>
    return false;<br>
  }<br>
<br>
-void BinaryOperator::setHasNoUnsignedWrap(bool b) {<br>
-  cast<OverflowingBinaryOperator>(this)->setHasNoUnsignedWrap(b);<br>
-}<br>
-<br>
-void BinaryOperator::setHasNoSignedWrap(bool b) {<br>
-  cast<OverflowingBinaryOperator>(this)->setHasNoSignedWrap(b);<br>
-}<br>
-<br>
-void BinaryOperator::setIsExact(bool b) {<br>
-  cast<PossiblyExactOperator>(this)->setIsExact(b);<br>
-}<br>
-<br>
-bool BinaryOperator::hasNoUnsignedWrap() const {<br>
-  return cast<OverflowingBinaryOperator>(this)->hasNoUnsignedWrap();<br>
-}<br>
-<br>
-bool BinaryOperator::hasNoSignedWrap() const {<br>
-  return cast<OverflowingBinaryOperator>(this)->hasNoSignedWrap();<br>
-}<br>
-<br>
-bool BinaryOperator::isExact() const {<br>
-  return cast<PossiblyExactOperator>(this)->isExact();<br>
-}<br>
-<br>
-void BinaryOperator::copyIRFlags(const Value *V) {<br>
-  // Copy the wrapping flags.<br>
-  if (auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {<br>
-    setHasNoSignedWrap(OB->hasNoSignedWrap());<br>
-    setHasNoUnsignedWrap(OB->hasNoUnsignedWrap());<br>
-  }<br>
-<br>
-  // Copy the exact flag.<br>
-  if (auto *PE = dyn_cast<PossiblyExactOperator>(V))<br>
-    setIsExact(PE->isExact());<br>
-<br>
-  // Copy the fast-math flags.<br>
-  if (auto *FP = dyn_cast<FPMathOperator>(V))<br>
-    copyFastMathFlags(FP->getFastMathFlags());<br>
-}<br>
-<br>
-void BinaryOperator::andIRFlags(const Value *V) {<br>
-  if (auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {<br>
-    setHasNoSignedWrap(hasNoSignedWrap() & OB->hasNoSignedWrap());<br>
-    setHasNoUnsignedWrap(hasNoUnsignedWrap() & OB-<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
hasNoUnsignedWrap());<br>
</blockquote>
-  }<br>
-<br>
-  if (auto *PE = dyn_cast<PossiblyExactOperator>(V))<br>
-    setIsExact(isExact() & PE->isExact());<br>
-<br>
-  if (auto *FP = dyn_cast<FPMathOperator>(V)) {<br>
-    FastMathFlags FM = getFastMathFlags();<br>
-    FM &= FP->getFastMathFlags();<br>
-    copyFastMathFlags(FM);<br>
-  }<br>
-}<br>
-<br>
<br>
  //===----------------------------------------------------------------------===//<br>
  //                             FPMathOperator Class<br>
<br>
Modified: llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
<br>
</blockquote>
project/llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp?rev=267111&r1=2671<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
10&r2=267111&view=diff<br>
<br>
</blockquote>
==========================================================<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
====================<br>
--- llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp Fri Apr 22 01:37:45 2016<br>
@@ -153,7 +153,7 @@ bool DenseMapInfo<SimpleValue>::isEqual(<br>
<br>
    if (LHSI->getOpcode() != RHSI->getOpcode())<br>
      return false;<br>
-  if (LHSI->isIdenticalTo(RHSI))<br>
+  if (LHSI->isIdenticalToWhenDefined(RHSI))<br>
      return true;<br>
<br>
    // If we're not strictly identical, we still might be a commutable instruction<br>
@@ -165,15 +165,6 @@ bool DenseMapInfo<SimpleValue>::isEqual(<br>
             "same opcode, but different instruction type?");<br>
      BinaryOperator *RHSBinOp = cast<BinaryOperator>(RHSI);<br>
<br>
-    // Check overflow attributes<br>
-    if (isa<OverflowingBinaryOperator>(LHSBinOp)) {<br>
-      assert(isa<OverflowingBinaryOperator>(RHSBinOp) &&<br>
-             "same opcode, but different operator type?");<br>
-      if (LHSBinOp->hasNoUnsignedWrap() != RHSBinOp-<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
hasNoUnsignedWrap() ||<br>
</blockquote>
-          LHSBinOp->hasNoSignedWrap() != RHSBinOp->hasNoSignedWrap())<br>
-        return false;<br>
-    }<br>
-<br>
      // Commuted equality<br>
      return LHSBinOp->getOperand(0) == RHSBinOp->getOperand(1) &&<br>
             LHSBinOp->getOperand(1) == RHSBinOp->getOperand(0);<br>
@@ -584,6 +575,8 @@ bool EarlyCSE::processNode(DomTreeNode *<br>
        // See if the instruction has an available value.  If so, use it.<br>
        if (Value *V = AvailableValues.lookup(Inst)) {<br>
          DEBUG(dbgs() << "EarlyCSE CSE: " << *Inst << "  to: " << *V << '\n');<br>
+        if (auto *I = dyn_cast<Instruction>(V))<br>
+          I->andIRFlags(Inst);<br>
          Inst->replaceAllUsesWith(V);<br>
          Inst->eraseFromParent();<br>
          Changed = true;<br>
<br>
Added: llvm/trunk/test/Transforms/EarlyCSE/flags.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
<br>
</blockquote>
project/llvm/trunk/test/Transforms/EarlyCSE/flags.ll?rev=267111&view=aut<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
o<br>
<br>
</blockquote>
==========================================================<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
====================<br>
--- llvm/trunk/test/Transforms/EarlyCSE/flags.ll (added)<br>
+++ llvm/trunk/test/Transforms/EarlyCSE/flags.ll Fri Apr 22 01:37:45 2016<br>
@@ -0,0 +1,18 @@<br>
+; RUN: opt -early-cse -S < %s | FileCheck %s<br>
+<br>
+declare void @use(i1)<br>
+<br>
+define void @test1(float %x, float %y) {<br>
+entry:<br>
+  %cmp1 = fcmp nnan oeq float %y, %x<br>
+  %cmp2 = fcmp oeq float %x, %y<br>
+  call void @use(i1 %cmp1)<br>
+  call void @use(i1 %cmp2)<br>
+  ret void<br>
+}<br>
+<br>
+; CHECK-LABEL: define void @test1(<br>
+; CHECK: %[[cmp:.*]] = fcmp oeq float %y, %x<br>
+; CHECK-NEXT: call void @use(i1 %[[cmp]])<br>
+; CHECK-NEXT: call void @use(i1 %[[cmp]])<br>
+; CHECK-NEXT: ret void<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a>llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a>llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote>
_______________________________________________<br>
llvm-commits mailing list<br>
<a>llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
<br>
</blockquote>
</blockquote>