http://llvm.org/bugs/show_bug.cgi?id=14059

             Bug #: 14059
           Summary: [SROA] New SRoA regression with ABI conversion
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified


It's not clear to me yet who is to blame, but new SROA is triggering in poor
code on the following example. This is due to the interaction between SROA,
inlining, and ABI conversion. With old SROA we cleaned things up nicely, but
with new SROA we are ending up with gratuitously ugly IR.

This is the root cause of a ~8% regression on
SingleSource/Benchmarks/Misc/mandel.c on ARM.

--
$ cat t.c
double __complex__ accum;
static void emit(double __complex__ X) {
  accum += X;
}

void f0() {
  double __complex__ c = 1 + 1.0i;
  emit(c);
}


$ daclang -target armv7-apple-darwin -flto -O3 -S -o - t.c
; ModuleID = 't.c'
target datalayout =
"e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32"
target triple = "thumbv7-apple-ios3.0.0"

@accum = common global { double, double } zeroinitializer, align 8

define void @f0() nounwind ssp {
entry:
  %X.sroa.0.i = alloca double, align 8
  %X.sroa.1.i = alloca double, align 8
  %X.sroa.0.i.0.cast13 = bitcast double* %X.sroa.0.i to i8*
  call void @llvm.lifetime.start(i64 8, i8* %X.sroa.0.i.0.cast13)
  %X.sroa.1.i.0.cast11 = bitcast double* %X.sroa.1.i to i8*
  call void @llvm.lifetime.start(i64 8, i8* %X.sroa.1.i.0.cast11)
  %X.sroa.0.i.0.cast14 = bitcast double* %X.sroa.0.i to i32*
  store i32 0, i32* %X.sroa.0.i.0.cast14, align 8
  %X.sroa.0.i.4.raw_idx = getelementptr inbounds i8* %X.sroa.0.i.0.cast13, i32
4
  %X.sroa.0.i.4.cast = bitcast i8* %X.sroa.0.i.4.raw_idx to i32*
  store i32 1072693248, i32* %X.sroa.0.i.4.cast, align 4
  %X.sroa.1.i.0.cast12 = bitcast double* %X.sroa.1.i to i32*
  store i32 0, i32* %X.sroa.1.i.0.cast12, align 8
  %X.sroa.1.i.4.raw_idx = getelementptr inbounds i8* %X.sroa.1.i.0.cast11, i32
4
  %X.sroa.1.i.4.cast = bitcast i8* %X.sroa.1.i.4.raw_idx to i32*
  store i32 1072693248, i32* %X.sroa.1.i.4.cast, align 4
  %X.real.i = load double* %X.sroa.0.i, align 8
  %X.imag.i = load double* %X.sroa.1.i, align 8
  %accum.real.i = load double* getelementptr inbounds ({ double, double }*
@accum, i32 0, i32 0), align 8
  %accum.imag.i = load double* getelementptr inbounds ({ double, double }*
@accum, i32 0, i32 1), align 8
  %add.r.i = fadd double %X.real.i, %accum.real.i
  %add.i.i = fadd double %X.imag.i, %accum.imag.i
  store double %add.r.i, double* getelementptr inbounds ({ double, double }*
@accum, i32 0, i32 0), align 8
  store double %add.i.i, double* getelementptr inbounds ({ double, double }*
@accum, i32 0, i32 1), align 8
  call void @llvm.lifetime.end(i64 8, i8* %X.sroa.0.i.0.cast13)
  call void @llvm.lifetime.end(i64 8, i8* %X.sroa.1.i.0.cast11)
  ret void
}

declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind

declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind



$ daclang -target armv7-apple-darwin -flto -O3 -S -o - t.c -mllvm
-use-new-sroa=0
; ModuleID = 't.c'
target datalayout =
"e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32"
target triple = "thumbv7-apple-ios3.0.0"

@accum = common global { double, double } zeroinitializer, align 8

define void @f0() nounwind ssp {
entry:
  %accum.real.i = load double* getelementptr inbounds ({ double, double }*
@accum, i32 0, i32 0), align 8
  %accum.imag.i = load double* getelementptr inbounds ({ double, double }*
@accum, i32 0, i32 1), align 8
  %add.r.i = fadd double %accum.real.i, 1.000000e+00
  %add.i.i = fadd double %accum.imag.i, 1.000000e+00
  store double %add.r.i, double* getelementptr inbounds ({ double, double }*
@accum, i32 0, i32 0), align 8
  store double %add.i.i, double* getelementptr inbounds ({ double, double }*
@accum, i32 0, i32 1), align 8
  ret void
}
--

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to