[InstCombine] Remove weaker fence adjacent to a stronger fence
authorAnna Thomas <anna@azul.com>
Fri, 28 Jan 2022 21:45:04 +0000 (13:45 -0800)
committerAnna Thomas <anna@azul.com>
Tue, 1 Feb 2022 19:05:34 +0000 (11:05 -0800)
commit4fc52db116033253ad5b078b317a9f7ae0db87d2
tree7dfdc03ddd746d792a8273558542174aa6b56170
parent91fb66cf91ae557d45bde7931cbb364f1c08d245
[InstCombine] Remove weaker fence adjacent to a stronger fence

We have an instCombine rule to remove identical consecutive fences.
We can extend this to remove weaker fences when we have consecutive stronger
fence.

As stated in the LangRef, a fence with a stronger ordering also implies
ordering weaker than itself: "A fence which has seq_cst ordering, in addition to
having both acquire and release semantics specified above, participates in the
global program order of other seq_cst operations and/or fences."

Reviewed-By: reames
Differential Revision: https://reviews.llvm.org/D118607
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/consecutive-fences.ll