how to turn off conversion of add's into or's (in address calculations)

It seems some optimization pass converts some address computation add's into or's when it knows it's allowed due correct alignment.

How do I turn this off keep the address calculations as adds?

HI Helkki,

I guess instcombine does that. See InstCombineAddSub.cpp:1107. The optimization there is more general than converting address computation adds. If A and B don’t have common bits, instcombine converts A + B to A | B. I am not aware of any configuration to turn this particular optimization off. If you just want to experiment, you can always change the code. Or you can improve your analysis/optimization to treat such OR as ADD.

Ignore if you already know this: you can run “opt -O3 -print-after-all” to figure out which optimization pass does a certain thing.

Jingyue

Add the IR level, most / nearly all address calculations are hidden in GEPs. They are only really exposed later in SelectionDAG, so DAGCombiner is probably doing this

Both DAG combiner and inst-combine do it. Also, there is some code in PEI(?) that does that too when generating addressing code for frame objects. You'd need to, ahem, turn it off, in all these places...

-Krzysztof