Skip to content

Convert CondExp to a ternary operator instead of if/else #94

@ShrutheeshIR

Description

@ShrutheeshIR

Hello,

Thanks for the great repo. I'm simple using conditional expressions, i.e.

v = CondExpLt(a, b, a, 0)

which compiles and provides an if/else statement, somewhere of the form

if x[15] < x[23]
x[16] = x[16]
else
x[16] = 0

However, I'd like to output a ternary operator, since I believe that (1) it is nicer and has no branching and (2) it follows the same CondExp pattern.

Ideally I'd like x[16] = (x[15] < x[23]) ? x[15] : 0

Could I get some tips/direction on how I can go about that? I'm looking at

CG<Base> result(*handler->makeNode(op,{left.argument(), right.argument(), trueCase.argument(), falseCase.argument()}));
, but feel a bit lost to get what I want. Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions