Files
clang-p2996/llvm/test/CodeGen/PowerPC/pr48527.ll
Roman Lebedev 428f36401b Reland "[SimplifyCFG] FoldBranchToCommonDest(): deal with mismatched IV's in PHI's in common successor block"
This reverts commit 37b8f09a4b,
and returns commit 1bd0b82e50.
The miscompile was in InstCombine, and it has been addressed.

This tries to approach the problem noted by @arsenm:
terrible codegen for `__builtin_fpclassify()`:
https://godbolt.org/z/388zqdE37

Just because the PHI in the common successor happens to have different
incoming values for these two blocks, doesn't mean we have to give up.
It's quite easy to deal with this, we just need to produce a select:
https://alive2.llvm.org/ce/z/000srb

Now, the cost model for this transform is rather overly strict,
so this will basically never fire. We tally all (over all preds)
the selects needed to the NumBonusInsts

Differential Revision: https://reviews.llvm.org/D139275
2022-12-17 05:18:54 +03:00

69 lines
2.5 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -relocation-model=pic -verify-machineinstrs < %s \
; RUN: -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 | FileCheck %s
%struct.e.0.12.28.44.104.108.112.188 = type { i32 }
%struct.t.1.13.29.45.105.109.113.189 = type { i64, i64 }
@g = external local_unnamed_addr global %struct.e.0.12.28.44.104.108.112.188, align 4
@aj = external thread_local local_unnamed_addr global %struct.t.1.13.29.45.105.109.113.189, align 8
define void @_ZNK1q1rEv() local_unnamed_addr #0 align 2 {
; CHECK-LABEL: _ZNK1q1rEv:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: mflr 0
; CHECK-NEXT: std 30, -16(1) # 8-byte Folded Spill
; CHECK-NEXT: stdu 1, -48(1)
; CHECK-NEXT: std 0, 64(1)
; CHECK-NEXT: addis 4, 2, .LC0@toc@ha
; CHECK-NEXT: lwz 3, 0(3)
; CHECK-NEXT: ld 4, .LC0@toc@l(4)
; CHECK-NEXT: addi 3, 3, -1
; CHECK-NEXT: .p2align 5
; CHECK-NEXT: .LBB0_1: # %monotonic.i
; CHECK-NEXT: #
; CHECK-NEXT: lwz 5, 0(4)
; CHECK-NEXT: cmpwi 1, 3, 0
; CHECK-NEXT: addi 3, 3, -1
; CHECK-NEXT: andi. 5, 5, 255
; CHECK-NEXT: crorc 20, 6, 2
; CHECK-NEXT: bc 4, 20, .LBB0_1
; CHECK-NEXT: # %bb.2: # %if.end
; CHECK-NEXT: crnot 20, 2
; CHECK-NEXT: li 3, 0
; CHECK-NEXT: li 4, 8
; CHECK-NEXT: isel 30, 4, 3, 20
; CHECK-NEXT: addis 3, 2, aj@got@tlsgd@ha
; CHECK-NEXT: addi 3, 3, aj@got@tlsgd@l
; CHECK-NEXT: bl __tls_get_addr(aj@tlsgd)
; CHECK-NEXT: nop
; CHECK-NEXT: li 4, 1
; CHECK-NEXT: stdx 4, 3, 30
; CHECK-NEXT: addi 1, 1, 48
; CHECK-NEXT: ld 0, 16(1)
; CHECK-NEXT: ld 30, -16(1) # 8-byte Folded Reload
; CHECK-NEXT: mtlr 0
; CHECK-NEXT: blr
entry:
%0 = load i32, ptr undef, align 4
br label %monotonic.i
for.cond.i: ; preds = %monotonic.i
%exitcond.not = icmp eq i32 %inc.i, %0
br i1 %exitcond.not, label %if.end, label %monotonic.i
monotonic.i: ; preds = %for.cond.i, %entry
%i.018.i = phi i32 [ %inc.i, %for.cond.i ], [ 0, %entry ]
%1 = load atomic i32, ptr @g monotonic, align 4
%conv.i = trunc i32 %1 to i8
%tobool.not.i = icmp eq i8 %conv.i, 0
%inc.i = add nuw nsw i32 %i.018.i, 1
br i1 %tobool.not.i, label %for.cond.i, label %if.end
if.end: ; preds = %monotonic.i, %for.cond.i
%.sink = phi ptr [ getelementptr inbounds (%struct.t.1.13.29.45.105.109.113.189, ptr @aj, i64 0, i32 1), %monotonic.i ], [ @aj, %for.cond.i ]
store i64 1, ptr %.sink, align 8
ret void
}
attributes #0 = { nounwind }