If a select instruction tests the returned flag of a cmpxchg instruction and selects between the returned value of the cmpxchg instruction and its compare operand, the result of the select will always be equal to its false value.
For example, in the code below %2 is the original value located at %ptr prior to any potential update. If the cmpxchg operation succeeds (%1 is true), %2 and %compare must be equal. Thus, the result of the select is always equal to %2.
%0 = cmpxchg i64* %ptr, i64 %compare, i64 %new_value seq_cst seq_cst %1 = extractvalue { i64, i1 } %0, 1 %2 = extractvalue { i64, i1 } %0, 0 %3 = select i1 %1, i64 %compare, i64 %2