aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUtils.cpp
diff options
context:
space:
mode:
authorJuneyoung Lee <aqjune@gmail.com>2021-01-13 09:33:21 +0900
committerJuneyoung Lee <aqjune@gmail.com>2021-01-13 09:36:52 +0900
commit25eb7b08ba77a0b7c9c938490444bb8b5121233c (patch)
tree72efb16420a01172f5cff1ab90d0dfc8621282a5 /llvm/lib/Transforms/Utils/LoopUtils.cpp
parent76643c48cdddfa220680f1ab4a83829bd83faa7a (diff)
downloadllvm-25eb7b08ba77a0b7c9c938490444bb8b5121233c.zip
llvm-25eb7b08ba77a0b7c9c938490444bb8b5121233c.tar.gz
llvm-25eb7b08ba77a0b7c9c938490444bb8b5121233c.tar.bz2
[DAGCombiner] Fold BRCOND(FREEZE(COND)) to BRCOND(COND)
This patch resolves the suboptimal codegen described in http://llvm.org/pr47873 . When CodeGenPrepare lowers select into a conditional branch, a freeze instruction is inserted. It is then translated to `BRCOND(FREEZE(SETCC))` in SelDag. The `FREEZE` in the middle of `SETCC` and `BRCOND` was causing a suboptimal code generation however. This patch adds `BRCOND(FREEZE(cond))` -> `BRCOND(cond)` fold to DAGCombiner to remove the `FREEZE`. To make this optimization sound, `BRCOND(UNDEF)` simply should nondeterministically jump to the branch or not, rather than raising UB. It wasn't clear what happens when the condition was undef according to the comments in ISDOpcodes.h, however. I updated the comments of `BRCOND` to make it explicit (as well as `BR_CC`, which is also a conditional branch instruction). Note that it diverges from the semantics of `br` instruction in IR, which is explicitly UB. Since the UB semantics was necessary to explain optimizations that use branching conditions, and SelDag doesn't seem to have such optimization, I think this divergence is okay. Reviewed By: spatel Differential Revision: https://reviews.llvm.org/D92015
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
0 files changed, 0 insertions, 0 deletions