Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regressions for conditional code gen from clang 10 to 11 #47217

Closed
llvmbot opened this issue Oct 16, 2020 · 5 comments
Closed

Regressions for conditional code gen from clang 10 to 11 #47217

llvmbot opened this issue Oct 16, 2020 · 5 comments
Labels
backend:X86 bugzilla Issues migrated from bugzilla

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 16, 2020

Bugzilla Link 47873
Resolution FIXED
Resolved on Jan 13, 2021 01:28
Version 11.0
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @topperc,@davidbolvansky,@aqjune,@RKSimon,@phoebewang,@rotateright
Fixed by commit(s) 25eb7b0

Extended Description

Small repro here: https://godbolt.org/z/xPPGMv

11.0 and trunk both produce the "cmp edx, ecx" / "seta cl" / "test cl, 1" / "jne label" construction that serves no purpose I can discern; 10.0.1 and earlier used the expected "cmp edx, ecx" / "ja label".

This function makes for a particularly simple reproducer but we're seeing instances of this in many places in our code base.

@topperc
Copy link
Collaborator

topperc commented Oct 16, 2020

I think this has something to do with a freeze instruction being inserted in CodeGenPrepare.

@aqjune
Copy link
Contributor

aqjune commented Oct 17, 2020

Yes, it is due to CodeGenPrepare's select cond -> br freeze(cond):

  %cmp = icmp ugt i32 %math, %1
  %cond = select i1 %ov, i32 %0, i32 %1
  %x.addr.0.frozen = freeze i1 %cmp
  br i1 %x.addr.0.frozen, label %select.end, label %select.false, !prof !​7

select.false:                                     ; preds = %entry
  br label %select.end

select.end:                                       ; preds = %entry, %select.false
  %x.addr.0 = phi i32 [ %cond, %entry ], [ %x, %select.false ]
  ret i32 %x.addr.0

After X86 DAG->DAG Instruction Selection, it becomes:

bb.0.entry:
  ...
  %12:gr8 = SETCCr 7, implicit $eflags           
  %13:gr8 = COPY killed %12:gr8                  
  TEST8ri killed %13:gr8, 1, implicit-def $eflags
  JCC_1 %bb.2, 5, implicit $eflags               
  JMP_1 %bb.1

Without freeze:

  ...
  JCC_1 %bb.2, 7, implicit $eflags
  JMP_1 %bb.1

I'm seeing whether it can be addressed at instruction selection level.

@davidbolvansky
Copy link
Collaborator

Any progress?

@aqjune
Copy link
Contributor

aqjune commented Dec 9, 2020

The patch link is here: https://reviews.llvm.org/D92015

@aqjune
Copy link
Contributor

aqjune commented Jan 13, 2021

Should be fixed now

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

4 participants