Page MenuHomePhabricator

[WebAssembly] Lower away condition truncations for scalar selects
ClosedPublic

Authored by tlively on Oct 24 2018, 3:07 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

tlively created this revision.Oct 24 2018, 3:07 PM

It seems only 1 can be a possible condition value from a valid LLVM IR, and if that's the case, I think what we need in this case is UndefinedBooleanContent. And I guess that should be the case for all other wasm instructions, but if we comment out this line, a bunch of test fails... Not sure why we need that line and what makes this case exceptional. Could you check?

It seems only 1 can be a possible condition value from a valid LLVM IR, and if that's the case, I think what we need in this case is UndefinedBooleanContent. And I guess that should be the case for all other wasm instructions, but if we comment out this line, a bunch of test fails... Not sure why we need that line and what makes this case exceptional. Could you check?

I checked it out. The BooleanContents value is used to describe both how bools are produced and how bools are consumed. ZeroOrOneBooleanContent is a correct value for WebAssembly because all of our instructions that produce bools produce either zero or one. Setting the BooleanContents to UndefinedBooleanContent causes LLVM to emit and 1 after every instruction that produces a bool (or at least after instructions that produce bools that are returned from functions). That is why the tests are failing. I'm not sure why LLVM explicitly zeros the high bits instead of leaving them undefined.

I suppose ideally we would be able to separately specify that instructions that produce bools produce either zeros or ones and instructions that consume bools can consume zeros or nonzeros, rather than using a single configuration option for both producers and consumers of bools.

aheejin accepted this revision.Oct 25 2018, 6:03 PM

Thanks!

This revision is now accepted and ready to land.Oct 25 2018, 6:03 PM
This revision was automatically updated to reflect the committed changes.