Conditional branches, or more exactly OP_CBR, can't accept arbitrary expression as condition. it is required to have an integer value. Fix this by adding a comparison against zero. --- linearize.c | 2 +- validation/linear/call-complex-pointer.c | 10 +++--- validation/loop-linearization.c | 44 ++++++++++++------------ validation/optim/call-inlined.c | 4 +-- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/linearize.c b/linearize.c index 7aa7fd4c3..2b950210e 100644 --- a/linearize.c +++ b/linearize.c @@ -1706,7 +1706,7 @@ static pseudo_t linearize_cond_branch(struct entrypoint *ep, struct expression * return linearize_cond_branch(ep, expr->unop, bb_false, bb_true); /* fall through */ default: { - cond = linearize_expression(ep, expr); + cond = linearize_expression_to_bool(ep, expr); add_branch(ep, expr, cond, bb_true, bb_false); return VOID; diff --git a/validation/linear/call-complex-pointer.c b/validation/linear/call-complex-pointer.c index ea8232f12..dc0ab07b3 100644 --- a/validation/linear/call-complex-pointer.c +++ b/validation/linear/call-complex-pointer.c @@ -18,14 +18,14 @@ foo: br .L4 .L3: - ptrcast.64 %r5 <- (64) %arg3 - phisrc.64 %phi2 <- %r5 + ptrcast.64 %r6 <- (64) %arg3 + phisrc.64 %phi2 <- %r6 br .L4 .L4: - phi.64 %r6 <- %phi1, %phi2 - call.32 %r7 <- %r6, %arg4 - ret.32 %r7 + phi.64 %r7 <- %phi1, %phi2 + call.32 %r8 <- %r7, %arg4 + ret.32 %r8 * check-output-end diff --git a/validation/loop-linearization.c b/validation/loop-linearization.c index 25c6dfb87..051e04534 100644 --- a/validation/loop-linearization.c +++ b/validation/loop-linearization.c @@ -56,8 +56,8 @@ ffor: br .L7 .L2: - add.32 %r7 <- %r1(i), $1 - phisrc.32 %phi6(i) <- %r7 + add.32 %r8 <- %r1(i), $1 + phisrc.32 %phi6(i) <- %r8 br .L4 .L3: @@ -65,8 +65,8 @@ ffor: br .L7 .L7: - phi.32 %r5 <- %phi1(return), %phi2(return) - ret.32 %r5 + phi.32 %r6 <- %phi1(return), %phi2(return) + ret.32 %r6 fwhile: @@ -76,21 +76,21 @@ fwhile: br .L12 .L12: - phi.32 %r8(i) <- %phi11(i), %phi12(i) - setlt.32 %r9 <- %r8(i), $10 - cbr %r9, .L9, .L11 + phi.32 %r9(i) <- %phi11(i), %phi12(i) + setlt.32 %r10 <- %r9(i), $10 + cbr %r10, .L9, .L11 .L9: - call.32 %r11 <- p, %r8(i) - cbr %r11, .L14, .L13 + call.32 %r12 <- p, %r9(i) + cbr %r12, .L14, .L13 .L13: phisrc.32 %phi7(return) <- $0 br .L15 .L14: - add.32 %r14 <- %r8(i), $1 - phisrc.32 %phi12(i) <- %r14 + add.32 %r16 <- %r9(i), $1 + phisrc.32 %phi12(i) <- %r16 br .L12 .L11: @@ -98,8 +98,8 @@ fwhile: br .L15 .L15: - phi.32 %r12 <- %phi7(return), %phi8(return) - ret.32 %r12 + phi.32 %r14 <- %phi7(return), %phi8(return) + ret.32 %r14 fdo: @@ -109,27 +109,27 @@ fdo: br .L17 .L17: - phi.32 %r15(i) <- %phi16(i), %phi17(i) - call.32 %r16 <- p, %r15(i) - cbr %r16, .L18, .L20 + phi.32 %r17(i) <- %phi16(i), %phi17(i) + call.32 %r18 <- p, %r17(i) + cbr %r18, .L18, .L20 .L20: phisrc.32 %phi13(return) <- $0 br .L22 .L18: - add.32 %r19 <- %r15(i), $1 - setlt.32 %r20 <- %r15(i), $10 - phisrc.32 %phi17(i) <- %r19 - cbr %r20, .L17, .L19 + add.32 %r22 <- %r17(i), $1 + setlt.32 %r23 <- %r17(i), $10 + phisrc.32 %phi17(i) <- %r22 + cbr %r23, .L17, .L19 .L19: phisrc.32 %phi14(return) <- $1 br .L22 .L22: - phi.32 %r17 <- %phi13(return), %phi14(return) - ret.32 %r17 + phi.32 %r20 <- %phi13(return), %phi14(return) + ret.32 %r20 * check-output-end diff --git a/validation/optim/call-inlined.c b/validation/optim/call-inlined.c index 00698a4b1..f21b32949 100644 --- a/validation/optim/call-inlined.c +++ b/validation/optim/call-inlined.c @@ -22,8 +22,8 @@ int foo(int a, int b, int p) foo: .L0: <entry-point> - select.32 %r9 <- %arg3, %arg3, $0 - ret.32 %r9 + select.32 %r10 <- %arg3, %arg3, $0 + ret.32 %r10 * check-output-end -- 2.18.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html