StructurizeCFG: Directly invert cmp instructions
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 19 Apr 2017 18:29:07 +0000 (18:29 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 19 Apr 2017 18:29:07 +0000 (18:29 +0000)
commitd3406bc45c55a2e019cb30b31a7a7e5e6e0b9928
tree75faa5e204d2da74e1e0f9a800df0baecdcb307f
parent5945447d84320a8361be006e63dc942862adac63
StructurizeCFG: Directly invert cmp instructions

The most common case for a branch condition is
a single use compare. Directly invert the branch
predicate rather than adding a lot of xor i1 true
which the DAG will have to fold later.

This produces nicer to read structurizer output.

This produces some random changes in codegen
due to the DAG swapping branch conditions itself,
and then does a poor job of dealing with those
inverts.

llvm-svn: 300732
llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
llvm/test/CodeGen/AMDGPU/loop_break.ll
llvm/test/CodeGen/AMDGPU/multi-divergent-exit-region.ll
llvm/test/CodeGen/AMDGPU/nested-loop-conditions.ll
llvm/test/CodeGen/AMDGPU/ret_jump.ll
llvm/test/Transforms/StructurizeCFG/invert-compare.ll [new file with mode: 0644]
llvm/test/Transforms/StructurizeCFG/one-loop-multiple-backedges.ll
llvm/test/Transforms/StructurizeCFG/post-order-traversal-bug.ll