1*9880d681SAndroid Build Coastguard Worker; RUN: opt -loop-idiom -S < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:o-i64:64-i128:128-n32:64-S128" 4*9880d681SAndroid Build Coastguard Workertarget triple = "arm64-apple-ios8.0.0" 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker; When we replace the precondition with a ctpop, we need to ensure 7*9880d681SAndroid Build Coastguard Worker; that only the first branch reads the ctpop. The store prior 8*9880d681SAndroid Build Coastguard Worker; to that should continue to read from the original compare. 9*9880d681SAndroid Build Coastguard Worker 10*9880d681SAndroid Build Coastguard Worker; CHECK: %tobool.5 = icmp ne i32 %num, 0 11*9880d681SAndroid Build Coastguard Worker; CHECK: store i1 %tobool.5, i1* %ptr 12*9880d681SAndroid Build Coastguard Worker 13*9880d681SAndroid Build Coastguard Workerdefine internal fastcc i32 @num_bits_set(i32 %num, i1* %ptr) #1 { 14*9880d681SAndroid Build Coastguard Workerentry: 15*9880d681SAndroid Build Coastguard Worker %tobool.5 = icmp ne i32 %num, 0 16*9880d681SAndroid Build Coastguard Worker store i1 %tobool.5, i1* %ptr 17*9880d681SAndroid Build Coastguard Worker br i1 %tobool.5, label %for.body.lr.ph, label %for.end 18*9880d681SAndroid Build Coastguard Worker 19*9880d681SAndroid Build Coastguard Workerfor.body.lr.ph: ; preds = %entry 20*9880d681SAndroid Build Coastguard Worker br label %for.body 21*9880d681SAndroid Build Coastguard Worker 22*9880d681SAndroid Build Coastguard Workerfor.body: ; preds = %for.body.lr.ph, %for.body 23*9880d681SAndroid Build Coastguard Worker %count.07 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ] 24*9880d681SAndroid Build Coastguard Worker %num.addr.06 = phi i32 [ %num, %for.body.lr.ph ], [ %and, %for.body ] 25*9880d681SAndroid Build Coastguard Worker %sub = add i32 %num.addr.06, -1 26*9880d681SAndroid Build Coastguard Worker %and = and i32 %sub, %num.addr.06 27*9880d681SAndroid Build Coastguard Worker %inc = add nsw i32 %count.07, 1 28*9880d681SAndroid Build Coastguard Worker %tobool = icmp ne i32 %and, 0 29*9880d681SAndroid Build Coastguard Worker br i1 %tobool, label %for.body, label %for.end 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Workerfor.end: ; preds = %for.cond.for.end_crit_edge, %entry 32*9880d681SAndroid Build Coastguard Worker %count.0.lcssa = phi i32 [ %inc, %for.body ], [ 0, %entry ] 33*9880d681SAndroid Build Coastguard Worker ret i32 %count.0.lcssa 34*9880d681SAndroid Build Coastguard Worker}