[PATCH] D36858: [x86] Teach the cmov converter to aggressively convert cmovs with memory operands into control flow.
Chandler Carruth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 18 09:55:06 PDT 2017
chandlerc added a comment.
In https://reviews.llvm.org/D36858#845378, @aaboud wrote:
> Thanks Chandler for preparing the patch, the implementation looks elegant, however, it overlooked a case where the memory registers are a result of a previous CMOV instructions.
Doh, of course. I'll add a remapping step to generating unfolded load. Should be easy because we know that the load is always on one side so can just remap to one of the inputs.
> This is a small reproducer that result in bad MIR:
Sweet!
>
>
> target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
> target triple = "x86_64-unknown-unknown"
>
> define i32 @bar(i32* %a, i32* %b, i32 %n1, i32 %n2, i32 %d) #0 {
> entry:
> %cmp = icmp sgt i32 %n1, %n2
> %s = select i1 %cmp, i32* %a, i32* %b
> %p = getelementptr inbounds i32, i32* %s, i64 1
> %load = load i32, i32* %p, align 4
> %res = select i1 %cmp, i32 %d, i32 %load
>
> ret i32 %res
> }
>
> attributes #0 = {"target-cpu"="skylake"}
>
https://reviews.llvm.org/D36858
More information about the llvm-commits
mailing list